I have a dictionary Dictionary. Both the outer dictionary and the inner one have an equality comparer set(in my
Create an extension method which will copy the values from your case-sensitive dictionary to a new case-insensitive dictionary.
public static Dictionary ToCaseInsensitive(this Dictionary caseSensitiveDictionary)
{
var caseInsensitiveDictionary = new Dictionary(StringComparer.OrdinalIgnoreCase);
caseSensitiveDictionary.Keys.ToList()
.ForEach(k => caseInsensitiveDictionary[k] = caseSensitiveDictionary[k]);
return caseInsensitiveDictionary;
}
Usage:
var newDictionary = JsonConvert.DeserializeObject>(value)
.ToCaseInsensitive();
Although this works for me (and I like this solution due to its simplicity), please note the following caveats: