Create a Hashtable using a case-insensitive code provider and a case-insensitive comparer, : CaseInsensitiveHashCodeProvider « Collections Data Structure « C# / C Sharp






Create a Hashtable using a case-insensitive code provider and a case-insensitive comparer,

 
      
using System;
using System.Collections;
using System.Globalization;

public class SamplesHashtable  {
   public static void Main()  {
      Hashtable myHT1 = new Hashtable();
      myHT1.Add("FIRST", "Hello");
      myHT1.Add("SECOND", "World");
      myHT1.Add("THIRD", "3");

      Hashtable myHT2 = new Hashtable( new CaseInsensitiveHashCodeProvider(), new CaseInsensitiveComparer() );
      myHT2.Add("FIRST", "Hello");
      myHT2.Add("SECOND", "World");
      myHT2.Add("THIRD", "3");

   }

}

   
  








Related examples in the same category

1.Create Hashtable using a case-insensitive code provider and a case-insensitive comparer, based on the culture of the current thread.
2.Create a Hashtable using a case-insensitive code provider and a case-insensitive comparer, based on the InvariantCulture.
3.Create a Hashtable using a case-insensitive code provider and a case-insensitive comparer, based on the Turkish culture (tr-TR), where "I" is not the uppercase version of "i".
4.CaseInsensitiveComparer Class compares two objects for equivalence, ignoring the case of strings.