I'm working with a Dictionary in C# with .NET 3.5. I've created a Dictionary
object and passed in the <string, int
>StringComparer.Ordinal
equality comparer. When I do the following code, however, I don't get what I would expect:
Dictionary<string, int> theDictionary = new Dictionary<string, int>(StringComparer.Ordinal);
theDictionary.Add("First", 1);
bool exists = theDictionary.ContainsKey("FIRST"); // equals true, when it should not
What am I not seeing here?
Are you sure you didn't use StringComparer.OrdinalIgnoreCase?
This code prints false for me with C# v3.5 compiler: