Found 26504 Articles for Server Side Programming

How to get First Element of the Tuple in C#?

AmitDiwan
Updated on 06-Dec-2019 07:22:50

880 Views

To get the first element of the Tuple, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main(String[] args){       var tuple1 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500);       var tuple2 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500);       Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2));       Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode());       Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode());       Console.WriteLine("Tuple1 Item 5th = "+tuple1.Item5);       Console.WriteLine("Tuple2 Item 5th = "+tuple2.Item5);       Console.WriteLine("Tuple1 Item 1st ... Read More

Check if two ListDictionary objects are equal in C#

AmitDiwan
Updated on 06-Dec-2019 07:15:24

149 Views

To check if two ListDictionary objects are equal, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       ListDictionary dict1 = new ListDictionary();       dict1.Add("A", "Books");       dict1.Add("B", "Electronics");       dict1.Add("C", "Smart Wearables");       dict1.Add("D", "Pet Supplies");       dict1.Add("E", "Clothing");       dict1.Add("F", "Footwear");       Console.WriteLine("ListDictionary1 elements...");       foreach(DictionaryEntry d in dict1){          Console.WriteLine(d.Key + " " + d.Value);       }       ListDictionary dict2 ... Read More

Check if two List objects are equal in C#

AmitDiwan
Updated on 06-Dec-2019 07:09:29

397 Views

To check if two List objects are equal, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(String[] args){       List list1 = new List();       list1.Add("One");       list1.Add("Two");       list1.Add("Three");       list1.Add("Four");       list1.Add("Five");       Console.WriteLine("Elements in List1...");       foreach (string res in list1){          Console.WriteLine(res);       }       List list2 = new List();       list2.Add("India");       list2.Add("US");       list2.Add("UK");   ... Read More

Remove the element with the specified key from the Hashtable in C#

AmitDiwan
Updated on 06-Dec-2019 07:06:52

142 Views

To remove the element with the specified key from the Hashtable, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo {    public static void Main(){       Hashtable hash = new Hashtable(10);       hash.Add("1", "A");       hash.Add("2", "B");       hash.Add("3", "C");       hash.Add("4", "D");       hash.Add("5", "E");       hash.Add("6", "F");       hash.Add("7", "G");       hash.Add("8", "H");       hash.Add("9", "I");       hash.Add("10", "J");       Console.WriteLine("Hashtable Key and Value pairs...");       foreach(DictionaryEntry ... Read More

How to get Fifth Element of the Tuple in C#?

AmitDiwan
Updated on 06-Dec-2019 07:03:47

107 Views

To get the fifth element of the Tuple, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main(String[] args){       var tuple1 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500);       var tuple2 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500);       Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2));       Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode());       Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode());       Console.WriteLine("Tuple1 Item 5th = "+tuple1.Item5);       Console.WriteLine("Tuple2 Item 5th = "+tuple2.Item5);    } }OutputThis will produce the ... Read More

Getting an enumerator that iterates through LinkedList in C#

AmitDiwan
Updated on 06-Dec-2019 07:01:06

909 Views

To get an enumerator that iterates through LinkedList, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(){       LinkedList list = new LinkedList();       list.AddLast("A");       list.AddLast("B");       list.AddLast("C");       list.AddLast("D");       list.AddLast("E");       list.AddLast("F");       list.AddLast("G");       list.AddLast("H");       list.AddLast("I");       list.AddLast("J");       Console.WriteLine("Count of nodes = " + list.Count);       Console.WriteLine("Elements in LinkedList... (Enumerator iterating through LinkedList)");       LinkedList.Enumerator demoEnum ... Read More

Get the number of elements in the SortedSet in C#

AmitDiwan
Updated on 06-Dec-2019 06:56:50

130 Views

To get the number of elements in the SortedSet, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(){       SortedSet set1 = new SortedSet();       set1.Add("AB");       set1.Add("BC");       set1.Add("CD");       set1.Add("EF");       Console.WriteLine("Elements in SortedSet1...");       foreach (string res in set1){          Console.WriteLine(res);       }       Console.WriteLine("Count of elements in SorteSet1 = "+set1.Count);       SortedSet set2 = new SortedSet();       set2.Add("BC");       ... Read More

Get the number of elements contained in the Stack in C#

AmitDiwan
Updated on 06-Dec-2019 06:52:50

223 Views

To get the number of elements contained in the Stack, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(){       Stack stack = new Stack();       stack.Push("A");       stack.Push("B");       stack.Push("C");       stack.Push("D");       stack.Push("E");       stack.Push("F");       stack.Push("G");       stack.Push("H");       Console.WriteLine("Count of elements = "+stack.Count);       Console.WriteLine("Elements in Stack...");       foreach (string res in stack){          Console.WriteLine(res);       } ... Read More

Add an object to the end of the Queue - Enqueue Operation in C#

AmitDiwan
Updated on 06-Dec-2019 06:50:07

211 Views

To add an object to the end of the Queue, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(){       Queue queue = new Queue();       queue.Enqueue("Electronics");       queue.Enqueue("Accessories");       queue.Enqueue("Toys");       queue.Enqueue("Books");       queue.Enqueue("Furniture");       queue.Enqueue("Clothing");       queue.Enqueue("Footwear");       queue.Enqueue("Cookware");       queue.Enqueue("Pet Supplies");       Console.WriteLine("Elements in the Queue...");       foreach(var element in queue){          Console.WriteLine(element);       }       ... Read More

Convert Stack to array in C#

AmitDiwan
Updated on 06-Dec-2019 06:46:53

418 Views

To convert stack to the array, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(){       Stack stack = new Stack();       stack.Push("AB");       stack.Push("CD");       stack.Push("FG");       stack.Push("KL");       Console.WriteLine("Array...");       foreach(string i in stack){          Console.WriteLine(i);       }       string[] strArr = stack.ToArray();       Console.WriteLine("Convert Stack to Array...");       foreach(string i in strArr){          Console.WriteLine(i);       }   ... Read More

Advertisements