Samual Sam has Published 2492 Articles

How to convert Decimal to Binary using C#?

Samual Sam

Samual Sam

Updated on 22-Jun-2020 10:57:36

295 Views

Let’s say we want to convert the number 48 to binary.Firstly, set it and use the / and % operators and loop until the value is greater than 1 −decVal = 48; while (decVal >= 1) {    val = decVal / 2;    a += (decVal % 2).ToString(); ... Read More

LinkedList in C#

Samual Sam

Samual Sam

Updated on 22-Jun-2020 10:55:35

2K+ Views

System.Collections.Generic namespace is available in C# for LinkedList. The LinkedList class allows insertion and deletion of elements from the list at a fast pace.C# LinkedList class uses the concept of linked list. It allows us to insert and delete elements fastly. It can have duplicate elements. It is found in ... Read More

SortedMap Interface in C#

Samual Sam

Samual Sam

Updated on 22-Jun-2020 10:23:59

289 Views

Java has SortedMap Interface, whereas an equivalent of it in C# is SortedList.SortedList collection in C# use a key as well as an index to access the items in a list.A sorted list is a combination of an array and a hash table. It contains a list of items that ... Read More

C# program to list the difference between two lists

Samual Sam

Samual Sam

Updated on 22-Jun-2020 10:23:00

1K+ Views

To get the difference between two lists, firstly set two lists in C# −// first list List < string > list1 = new List < string > (); list1.Add("A"); list1.Add("B"); list1.Add("C"); list1.Add("D"); // second list List < string > list2 = new List < string > (); list2.Add("C"); list2.Add("D"); ... Read More

What is the type of elements of the jagged array in C#?

Samual Sam

Samual Sam

Updated on 22-Jun-2020 10:21:04

87 Views

A jagged array is an array of arrays, and therefore its elements are reference types and are initialized to null.Let us see how to work with Jagged array −Declare a jagged array −int [][] marks;Now, let us initialize it, wherein marks is an arrays of 5 integers −int[][] marks = ... Read More

What is unmanaged code in C#?

Samual Sam

Samual Sam

Updated on 22-Jun-2020 10:19:37

487 Views

The following states what is an unmanaged code −Applications that are not under the control of the CLR are unmanagedThe unsafe code or the unmanaged code is a code block that uses a pointer variable.The unsafe modifier allows pointer usage in unmanaged code.Here is the module showing how to declare ... Read More

C# program to convert floating to binary

Samual Sam

Samual Sam

Updated on 22-Jun-2020 10:19:09

554 Views

Let’s say the following is our float −float n = 50.5f;Take an empty string to display the binary value and loop until the value of our float variable is greater than 1 −string a = ""; while (n >= 1) {    a = (n % 2) + a; ... Read More

Socket Programming in C#

Samual Sam

Samual Sam

Updated on 22-Jun-2020 10:16:10

1K+ Views

The System.Net.Sockets namespace has a managed implementation of the Windows Sockets interface.It has two basic modes − synchronous and asynchronous.Let us see an example to work with System.Net.Sockets.TcpListener class −TcpListener l = new TcpListener(1234); l.Start(); // creating a socket Socket s = l.AcceptSocket(); Stream network = new NetworkStream(s);The following ... Read More

Find frequency of each word in a string in C#

Samual Sam

Samual Sam

Updated on 22-Jun-2020 10:14:23

627 Views

To find the frequency of each word in a string, you can try to run the following code −Example Live Demousing System; class Demo {    static int maxCHARS = 256;    static void calculate(String s, int[] cal) {       for (int i = 0; i < s.Length; i++) ... Read More

How to find the Current Context id of the Thread in C#?

Samual Sam

Samual Sam

Updated on 22-Jun-2020 10:11:35

531 Views

To create a new thread.Thread thread = Thread.CurrentThread; thread.Name = "My new Thread”;To get the current context id, use the ContextID property.Thread.CurrentContext.ContextIDLet us see the complete code −Example Live Demousing System; using System.Threading; namespace Demo {    class MyClass {       static void Main(string[] args) {       ... Read More

Advertisements