Csharp Articles

Page 20 of 196

Creating a Case-Sensitive HybridDictionary with specified initial size in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 149 Views

To create a case-sensitive HybridDictionary with specified initial size, the code is as follows −Exampleusing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       HybridDictionary myDict = new HybridDictionary(5, false);       myDict.Add("A", "AB");       myDict.Add("B", "BC");       myDict.Add("C", "DE");       myDict.Add("D", "FG");       myDict.Add("e", "fg");       Console.WriteLine("Key/Value pairs...");       foreach(DictionaryEntry de in myDict)       Console.WriteLine("Key = "+de.Key + ", Value = " + de.Value);    } }OutputThis will produce the following output −Key/Value pairs... Key = ...

Read More

Check if two ArrayList objects are equal in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 393 Views

To check if two ArrayList objects are equal, the code is as follows −Exampleusing System; using System.Collections; public class Demo {    public static void Main(String[] args){       ArrayList list1 = new ArrayList();       list1.Add("A");       list1.Add("B");       list1.Add("C");       list1.Add("D");       list1.Add("E");       list1.Add("F");       list1.Add("G");       list1.Add("H");       list1.Add("I");       Console.WriteLine("Elements in ArrayList1...");       foreach (string res in list1){          Console.WriteLine(res);       }       ArrayList list2 = ...

Read More

Creating a HybridDictionary with specified initial size in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 132 Views

To create a HybridDictionary with specified initial size, the code is as follows −Exampleusing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       HybridDictionary dict = new HybridDictionary(5);       dict.Add("A", "AB");       dict.Add("B", "BC");       dict.Add("C", "DE");       dict.Add("D", "FG");       dict.Add("E", "HI");       Console.WriteLine("Key/Value pairs...");       foreach(DictionaryEntry d in dict)       Console.WriteLine("Key = "+d.Key + ", Value = " + d.Value);    } }OutputThis will produce the following output −Key/Value pairs... Key = A, Value ...

Read More

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

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 133 Views

To check if a SortedSet is a subset of the specified collection, the code is as follows −Exampleusing 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");       ...

Read More

Check if two String objects have the same value in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 205 Views

To check if two String objects have the same value, the code is as follows −Exampleusing System; public class Demo {    public static void Main(String[] args){       string str1 = "John";       string str2 = "John";       Console.WriteLine("String 1 = "+str1);       Console.WriteLine("String 2 = "+str2);       Console.WriteLine("String 1 is equal to String 2: {0}", str1.Equals(str2));    } }OutputThis will produce the following output −String 1 = John String 2 = John String 1 is equal to String 2: TrueExampleLet us see another example −using System; public class Demo ...

Read More

Check if two HashSet objects are equal in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 426 Views

To check if two HashSet objects are equal, the code is as follows −Exampleusing System; using System.Collections.Generic; public class Demo {    public static void Main(String[] args) {       HashSet set1 = new HashSet();       set1.Add("A");       set1.Add("B");       set1.Add("C");       set1.Add("D");       set1.Add("E");       set1.Add("F");       set1.Add("G");       set1.Add("H");       Console.WriteLine("Elements in HashSet1...");       foreach (string res in set1) {          Console.WriteLine(res);       }       HashSet set2 = new HashSet(); ...

Read More

Check if two StringBuilder objects are Equal in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 173 Views

To check if two StringBuilder objects are equal, the code is as follows −Exampleusing System; using System.Text; public class Demo {    public static void Main(String[] args){       StringBuilder strBuilder1 = new StringBuilder("Tim");       StringBuilder strBuilder2 = new StringBuilder("Tom");       StringBuilder strBuilder3 = new StringBuilder();       strBuilder2 = strBuilder3;       Console.WriteLine("Is StringBuilder3 equal to StringBuilder2? = "+strBuilder3.Equals(strBuilder2));    } }OutputThis will produce the following output −Is StringBuilder3 equal to StringBuilder2? = TrueExampleLet us see another example −using System; using System.Text; public class Demo {    public static void Main(String[] args){ ...

Read More

Check if two HybridDictionary objects are equal in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 200 Views

To check if two HybridDictionary objects are equal, the code is as follows −Exampleusing 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 dict2 = ...

Read More

Check if two Tuple Objects are equal in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 189 Views

To check if two Tuple objects are equal, the code is as follows −Exampleusing System; public class Demo {    public static void Main(String[] args){       var tuple1 = Tuple.Create(150, 400, 500, 700, 100, 1200, 1500);       var tuple2 = Tuple.Create(150, 400, 500, 700, 100, 1200, 1500);       Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2));    } }OutputThis will produce the following output −Is Tuple1 equal to Tuple2? = TrueExampleLet us see another example −using System; public class Demo {    public static void Main(String[] args){       var tuple1 = Tuple.Create(150, 400, ...

Read More

Check if a SortedSet is a superset of the specified collection in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 146 Views

To check if a SortedSet is a superset of the specified collection, the code is as follows −Exampleusing 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);       }       SortedSet set2 = new SortedSet();       set2.Add("BC");       set2.Add("CD");       set2.Add("DE");       ...

Read More
Showing 191–200 of 1,951 articles
« Prev 1 18 19 20 21 22 196 Next »
Advertisements