Csharp Articles

Page 16 of 196

Check if the SortedSet contains a specific element in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 236 Views

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

Read More

Check if the Hashtable contains a specific value in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 279 Views

To check if the Hashtable contains a specific value, the code is as follows −Exampleusing System; using System.Collections; public class Demo {    public static void Main(){       Hashtable hash = new Hashtable();       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 entry in hash){ ...

Read More

Check if two BitArray objects are equal in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 411 Views

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

Read More

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

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 177 Views

To check if a SortedSet object is a proper 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(10);       set1.Add(20);       set1.Add(30);       set1.Add(40);       set1.Add(50);       set1.Add(60);       Console.WriteLine("Elements in SortedSet1...");       foreach (int res in set1){          Console.WriteLine(res);       }       SortedSet set2 = new SortedSet();       set2.Add(10);   ...

Read More

Get an ICollection containing the values in OrderedDictionary in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 585 Views

To get an ICollection containing the values in OrderedDictionary, the code is as follows −Exampleusing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       OrderedDictionary dict = new OrderedDictionary();       dict.Add("1", "One");       dict.Add("2", "Two");       dict.Add("3", "Three");       dict.Add("4", "Four");       dict.Add("5", "Five");       dict.Add("6", "Six");       dict.Add("7", "Seven");       dict.Add("8", "Eight");       ICollection col = dict.Values;       String[] strVal = new String[dict.Count];       col.CopyTo(strVal, 0);       ...

Read More

Check if Hashtable is read-only in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 178 Views

To check if Hashtable is read-only, the code is as follows −Exampleusing 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

Get the first node of the LinkedList in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 428 Views

To get the first node of the LinkedList, the code is as follows −Exampleusing 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("First Node = "+list.First.Value);       list.Clear();       Console.WriteLine("Count of ...

Read More

Check if the Hashtable contains a specific Key in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 359 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

Boolean.ToString(IFormatProvider) Method in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 558 Views

The Boolean.ToString() method in C# is used to convert the value of this instance to its equivalent string representation.SyntaxThe syntax is as follows −public string ToString (IFormatProvider provider);Above, the parameter provider is an IFormatProvider object.ExampleLet us now see an example −using System; using System.Globalization; public class Demo {    public static void Main(String[] args) {       bool val1 = true;       bool val2 = false;       Console.WriteLine("Value1 (Hashcode) = "+val1.GetHashCode());       Console.WriteLine("Value1 (TypeCode) = "+val1.GetTypeCode());       Console.WriteLine("Value2 (Hashcode) = "+val2.GetHashCode());       Console.WriteLine("Value2 (TypeCode) = "+val2.GetTypeCode());       ...

Read More

Check if two SortedSet objects are equal in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 257 Views

To check if two SortedSet objects are equal, the code is as follows −Exampleusing 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
Showing 151–160 of 1,951 articles
« Prev 1 14 15 16 17 18 196 Next »
Advertisements