C# – Case insensitive dictionary

If you want a case insensitive dictionary, use: In the Dictionary constructor you can specify how keys are compared. For string keys, the default is a case sensitive comparison. To make it case insensitive, you can pass in StringComparer.InvariantCultureIgnoreCase. Example I have a table that maps users to devices. The user-to-device mapping gets cached in … Read more C# – Case insensitive dictionary

KeyNotFoundException: The given key was not present in the dictionary

Problem The following exception is thrown when you try to get a value from a dictionary using a key that doesn’t exist in the dictionary: KeyNotFoundException: ‘The given key was not present in the dictionary.’ Consider the following the example: When the user enters a city name that isn’t in the dictionary, such as “New … Read more KeyNotFoundException: The given key was not present in the dictionary