Skip to main content

Create a case insensitive Hashtable in C#.

var ht = new Hashtable(StringComparer.InvariantCultureIgnoreCase);

ht.Add("one", "value");

if (!ht.ContainsKey("ONE"))
{
    ht.Add("ONE", "value");
}

foreach(DictionaryEntry de in ht)
{
    Console.WriteLine("Key = {0}, Value = {1}", de.Key, de.Value);
}

// --------------------------------
// Output:
// --------------------------------
// Key = one, Value = value