I'm kicking myself because I always just assumed that generic dictionaries in C#, i.e. Dictionary<string, object>, were case-sensitive. I always assumed that in order to have a case-insensitive dictionary, you had to do one of two things:
- public class CaseInsensitiveDictionary<TValue> : Dictionary<string, TValue> { ... }
- var item = myDictionary.Find(kvp=>kvp.Key.ToLower() == myKey.ToLower());
Actually, Dictionary<K,V> has a constructor that accepts a comparer object with which you can take advantage of prefab case-insensitive key-matching behavior.
Dictionary<string,object> myDictionary = new Dictionary<string,object>(StringComparer.InvariantCultureIgnoreCase);
I realized this upon stumbling across the MSDN documentation, which, of course, everyone reads for fun.
http://msdn.microsoft.com/en-us/library/ms132073.aspx