Found 26504 Articles for Server Side Programming

Get an ICollection containing the keys in HybridDictionary in C#

AmitDiwan
Updated on 05-Dec-2019 08:09:38

98 Views

To get an ICollection containing the keys in HybridDictionary, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo {    public static void Main(){       HybridDictionary dict = new HybridDictionary();       dict.Add("One", "Katie");       dict.Add("Two", "Andy");       dict.Add("Three", "Gary");       dict.Add("Four", "Mark");       dict.Add("Five", "Marie");       dict.Add("Six", "Sam");       dict.Add("Seven", "Harry");       dict.Add("Eight", "Kevin");       dict.Add("Nine", "Ryan");       String[] strArr = new String[dict.Count];       dict.Keys.CopyTo(strArr, 0);       for (int i ... Read More

Get an enumerator that iterates through the SortedDictionary in C#

AmitDiwan
Updated on 05-Dec-2019 08:06:48

141 Views

To get an enumerator that iterates through the SortedDictionary, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Generic; public class Demo {    public static void Main(){       SortedDictionarysortedDict = new SortedDictionary();       sortedDict.Add(100, "Mobile");       sortedDict.Add(200, "Laptop");       sortedDict.Add(300, "Desktop");       sortedDict.Add(400, "Speakers");       sortedDict.Add(500, "Headphone");       sortedDict.Add(600, "Earphone");       Console.WriteLine("SortedDictionary key-value pairs...");       IDictionaryEnumerator demoEnum = sortedDict.GetEnumerator();       while (demoEnum.MoveNext())          Console.WriteLine("Key = " + demoEnum.Key + ", Value = " + ... Read More

Get an enumerator that iterates through the ListDictionary in C#

AmitDiwan
Updated on 05-Dec-2019 08:03:44

148 Views

To get an enumerator that iterates through the ListDictionary, 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 ... Read More

Get an ICollection containing the values in ListDictionary in C#

AmitDiwan
Updated on 05-Dec-2019 08:00:18

149 Views

To get an ICollection containing the values in ListDictionary, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       ListDictionary listDict = new ListDictionary();       listDict.Add("1", "Laptop");       listDict.Add("2", "Tablet");       listDict.Add("3", "Desktop");       listDict.Add("4", "Speaker");       listDict.Add("5", "Earphone");       listDict.Add("6", "Headphone");       ICollection col = listDict.Values;       foreach(String s in col){          Console.WriteLine(s);       }    } }OutputThis will produce the following output −Laptop ... Read More

Get an enumerator that iterates through the HybridDictionary in C#

AmitDiwan
Updated on 05-Dec-2019 07:57:29

117 Views

To get an enumerator that iterates through the HybridDictionary, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       HybridDictionary dict1 = new HybridDictionary();       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("HybridDictionary1 elements...");       foreach(DictionaryEntry d in dict1){          Console.WriteLine(d.Key + " " + d.Value);       }       HybridDictionary ... Read More

Remove all objects from the Queue in C#

AmitDiwan
Updated on 05-Dec-2019 07:54:16

126 Views

To remove all objects from 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("Gary");       queue.Enqueue("Jack");       queue.Enqueue("Ryan");       queue.Enqueue("Kevin");       queue.Enqueue("Mark");       queue.Enqueue("Jack");       queue.Enqueue("Ryan");       queue.Enqueue("Kevin");       Console.Write("Count of elements = ");       Console.WriteLine(queue.Count);       queue.Clear();       Console.Write("Count of elements (updated) = ");       Console.WriteLine(queue.Count);    } }OutputThis will produce ... Read More

Remove all entries from the ListDictionary in C#

AmitDiwan
Updated on 05-Dec-2019 07:51:18

113 Views

To remove all entries from the ListDictionary, 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 a HashSet is a proper superset of the specified collection in C#

AmitDiwan
Updated on 05-Dec-2019 07:47:47

124 Views

To check if a HashSet is a proper superset of the specified collection, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(){       HashSet set1 = new HashSet();       set1.Add(30);       set1.Add(60);       set1.Add(70);       set1.Add(80);       set1.Add(100);       set1.Add(125);       set1.Add(150);       set1.Add(200);       Console.WriteLine("Elements in HashSet1");       foreach(int val in set1){          Console.WriteLine(val);       }       HashSet set2 = ... Read More

Remove all elements in a collection from a HashSet in C#

AmitDiwan
Updated on 05-Dec-2019 07:44:31

147 Views

To remove all elements in a collection from a HashSet, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(String[] args){       HashSet set1 = new HashSet();       set1.Add("Ryan");       set1.Add("Tom");       set1.Add("Andy");       set1.Add("Tim");       Console.WriteLine("Elements in HashSet1...");       foreach (string res in set1){          Console.WriteLine(res);       }       HashSet set2 = new HashSet();       set2.Add("John");       set2.Add("Jacob");       set2.Add("Ryan");       ... Read More

Remove all elements from the SortedSet in C#

AmitDiwan
Updated on 05-Dec-2019 07:40:29

142 Views

To remove all elements from 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);       }       SortedSet set2 = new SortedSet();       set2.Add("BC");       set2.Add("CD");       set2.Add("DE");       set2.Add("EF");       ... Read More

Advertisements