C# program to concat two or more Lists

Chandu yadav
Published on 15-Sep-2019 23:49:23
Set three lists − // three lists var list1 = new List<int>{3, 4}; var list2 = new List<int>{1, 2, 3}; var list3 = new List<int>{2, 5, 6}; Now, use the Concat mthod to concat the above lists − var res1 = list1.Concat(list2); var res2 = res1.Concat(list3); ... Read More

C# program to find Union of two or more Lists

Arjun Thakur
Published on 15-Sep-2019 23:49:23
Firstly, create lists − //three lists var list1 = new List{3, 4, 5}; var list2 = new List{1, 2, 3, 4, 5}; var list3 = new List{5, 6, 7, 8}; Use the union method to get the union of list1 and list2 − var res1 = list1.Union(list2); ... Read More

C# program to find Union of two or more Dictionaries

Chandu yadav
Published on 15-Sep-2019 23:49:23
Firstly, set both the dictionaries − Dictionary < string, int > dict1 = new Dictionary < string, int > (); dict1.Add("water", 1); dict1.Add("food", 2); Dictionary < string, int > dict2 = new Dictionary < string, int > (); dict2.Add("clothing", 3); dict2.Add("shelter", 4); Now, create HashSet and use UnionsWith() ... Read More

Layered Operating System

David Meador
Published on 15-Sep-2019 23:49:23
The operating system is split into various layers In the layered operating system and each of the layers have different functionalities. This type of operating system was created as an improvement over the early monolithic systems. Why Layering in Operating System? Layering provides a distinct advantage in an operating system. ... Read More

How to check if two Strings are anagrams of each other using C#?

Samual Sam
Published on 15-Sep-2019 23:49:23
Under anagram, another string would have the same characters present in the first string, but the order of characters can be different. Here, we are checking the following two strings − string str1 = "silent"; string str2 = "listen"; Convert both the strings into character array ... Read More

C# program to check whether a given string is Heterogram or not

karthikeya Boyini
Published on 15-Sep-2019 23:49:23
Heterogram for a string means the string isn’t having duplicate letters. For example − Mobile Cry Laptop Loop through each word of the string until the length of the string − for (int i = 0; i < len; i++) { ... Read More

How to Convert Hex String to Hex Number in C#?

karthikeya Boyini
Published on 15-Sep-2019 23:49:23
Firstly, set the Hex String − string str = "7D"; Now, use the Convert.ToSByte() method to convert the Hex string to Hex number − Console.WriteLine(Convert.ToSByte(str, 16)); Let us see the complete code − Example Live Demo using System; ... Read More

How to convert a tuple into an array in C#?

Samual Sam
Published on 15-Sep-2019 23:49:23
Firstly, set a tuple − Tuple<int, int> t = Tuple.Create(99, 53); Now, convert the tuple to an array − int[] arr = new int[]{t.Item1, t.Item2}; The following is the code to convert a tuple into an array − Example Live Demo ... Read More

How to convert a number from Decimal to Binary using recursion in C#?

karthikeya Boyini
Published on 15-Sep-2019 23:49:23
To get the binary of Decimal, using recursion, firstly set the decimal number − int dec = 30; Now pass the value to a function − public int displayBinary(int dec) { } Now, check the condition until the decimal value is 0 and using ... Read More

Merge two sorted arrays into a list using C#

Samual Sam
Published on 15-Sep-2019 23:49:23
To merge two sorted arrays into a list, firstly set two sorted arrays − int[] array1 = { 1, 2 }; int[] array2 = { 3, 4 }; Add it to a list and merge − var list = new List<int>(); for ... Read More
Advertisements