Found 26504 Articles for Server Side Programming

Check if a HashSet is a subset of the specified collection in C#

AmitDiwan
Updated on 04-Dec-2019 08:00:02

127 Views

To check if a HashSet is a subset 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("EF");       set1.Add("OP");       Console.WriteLine("Elements in HashSet1");       foreach(string val in set1){          Console.WriteLine(val);       }       HashSet set2 = new HashSet();       set2.Add("KL");       set2.Add("MN");       set2.Add("OP");       set2.Add("QR");       Console.WriteLine("Elements in HashSet2");   ... Read More

Check if two BitArray objects are equal in C#

AmitDiwan
Updated on 04-Dec-2019 07:55:59

360 Views

To check if two BitArray objects are equal, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo {    public static void Main(){       BitArray arr1 = new BitArray(2);       BitArray arr2 = new BitArray(2);       arr1[0] = false;       arr1[1] = true;       Console.WriteLine("Elements in BitArray1...");       foreach (bool res in arr1){          Console.WriteLine(res);       }       arr2[0] = false;       arr2[1] = true;       Console.WriteLine("Elements in BitArray2...");       foreach ... Read More

Get a collection of keys in the StringDictionary in C#

AmitDiwan
Updated on 04-Dec-2019 07:53:04

139 Views

To get a collection of keys in the StringDictionary, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       StringDictionary strDict1 = new StringDictionary();       strDict1.Add("U", "Electronics");       strDict1.Add("V", "Toys");       strDict1.Add("W", "Books");       strDict1.Add("X", "Accessories");       Console.WriteLine("StringDictionary1 elements...");       foreach(DictionaryEntry d in strDict1){          Console.WriteLine(d.Key + " " + d.Value);       }       Console.WriteLine("Does StringDictionary1 has key G? "+strDict1.ContainsKey("G"));       StringDictionary strDict2 = new ... Read More

Check if the StringDictionary contains a specific value in C#

AmitDiwan
Updated on 04-Dec-2019 07:47:23

140 Views

To check if the StringDictionary contains a specific value, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       StringDictionary strDict1 = new StringDictionary();       strDict1.Add("A", "John");       strDict1.Add("B", "Andy");       strDict1.Add("C", "Tim");       strDict1.Add("D", "Ryan");       strDict1.Add("E", "Kevin");       strDict1.Add("F", "Katie");       strDict1.Add("G", "Brad");       Console.WriteLine("StringDictionary1 elements...");       foreach(DictionaryEntry d in strDict1){          Console.WriteLine(d.Key + " " + d.Value);       }   ... Read More

Check if the StringDictionary contains a specific key in C#

AmitDiwan
Updated on 04-Dec-2019 07:38:54

157 Views

To check if the StringDictionary contains a specific key, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       StringDictionary strDict1 = new StringDictionary();       strDict1.Add("A", "John");       strDict1.Add("B", "Andy");       strDict1.Add("C", "Tim");       strDict1.Add("D", "Ryan");       strDict1.Add("E", "Kevin");       strDict1.Add("F", "Katie");       strDict1.Add("G", "Brad");       Console.WriteLine("StringDictionary1 elements...");       foreach(DictionaryEntry d in strDict1){          Console.WriteLine(d.Key + " " + d.Value);       }   ... Read More

Check if two SortedSet objects are equal in C#

AmitDiwan
Updated on 04-Dec-2019 07:34:29

215 Views

To check if two SortedSet objects are equal, 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(100);       set1.Add(200);       set1.Add(300);       set1.Add(400);       Console.WriteLine("Elements in SortedSet1...");       foreach (int res in set1) {          Console.WriteLine(res);       }       Console.WriteLine("Does the SortedSet1 contains the element 400? = "+set1.Contains(400));       SortedSet set2 = new SortedSet();       set2.Add(100);   ... Read More

Check if the Hashtable contains a specific Key in C#

AmitDiwan
Updated on 04-Dec-2019 07:30:49

314 Views

To check if Hashtable contains a specific key, the code is as follows −Exampleusing System; using System.Collections; public class Demo {    public static void Main()    public static void Main(){       Hashtable hash = new Hashtable();       hash.Add("One", "Katie");       hash.Add("Two", "John");       hash.Add("Three", "Barry");       hash.Add("Four", "Mark");       hash.Add("Five", "Harry");       hash.Add("Six", "Nathan");       hash.Add("Seven", "Tom");       hash.Add("Eight", "Andy");       hash.Add("Nine", "Illeana");       hash.Add("Ten", "Tim");       Console.WriteLine("Hashtable Key and Value pairs...");       ... Read More

Check if Hashtable is read-only in C#

AmitDiwan
Updated on 04-Dec-2019 07:26:35

144 Views

To check if Hashtable is read-only, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo {    public static void Main(){       Hashtable hash = new Hashtable();       hash.Add("One", "Katie");       hash.Add("Two", "John");       hash.Add("Three", "Barry");       hash.Add("Four", "");       hash.Add("Five", "Harry");       hash.Add("Six", "F");       hash.Add("Seven", "Tom");       hash.Add("Eight", "Andy");       hash.Add("Nine", "I");       hash.Add("Ten", "Tim");       Console.WriteLine("Hashtable Key and Value pairs...");       foreach(DictionaryEntry entry in hash){     ... Read More

Check if the SortedSet contains a specific element in C#

AmitDiwan
Updated on 04-Dec-2019 07:23:00

187 Views

To check if the SortedSet contains a specific element, 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("CD");       set1.Add("CD");       set1.Add("CD");       set1.Add("CD");       Console.WriteLine("Elements in SortedSet1...");       foreach (string res in set1){          Console.WriteLine(res);       }       Console.WriteLine("Does the SortedSet1 contains the element DE? = "+set1.Contains("DE"));       SortedSet set2 = new SortedSet();       set2.Add("BC");   ... Read More

Check if a Stack contains an element in C#

AmitDiwan
Updated on 04-Dec-2019 07:16:10

259 Views

To check if a Stack has elements, use the C# Contains() method. Following is the code −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(){       Stack stack = new Stack();       stack.Push(100);       stack.Push(150);       stack.Push(175);       stack.Push(200);       stack.Push(225);       stack.Push(250);       stack.Push(300);       stack.Push(400);       stack.Push(450);       stack.Push(500);       Console.WriteLine("Elements in the Stack:");       foreach(var val in stack){          Console.WriteLine(val);       ... Read More

Advertisements