Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Csharp Articles
Page 20 of 196
Creating a Case-Sensitive HybridDictionary with specified initial size in C#
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 MoreCheck if two ArrayList objects are equal in C#
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 MoreCreating a HybridDictionary with specified initial size in C#
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 MoreCheck if a SortedSet is a subset of the specified collection in C#
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 MoreCheck if two String objects have the same value in C#
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 MoreCheck if two HashSet objects are equal in C#
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 MoreCheck if two StringBuilder objects are Equal in C#
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 MoreCheck if two HybridDictionary objects are equal in C#
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 MoreCheck if two Tuple Objects are equal in C#
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 MoreCheck if a SortedSet is a superset of the specified collection in C#
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