No, Dictionary<string, string>
is not case-insensitive by default.
This can be easily shown with this little application:
using System;
using System.Collections.Generic;
public class MainClass
{
public static void Main(string[] args)
{
var newDict = new Dictionary<string, string>();
newDict.Add("a", "x");
Console.WriteLine(newDict.ContainsKey("a"));
Console.WriteLine(newDict.ContainsKey("A"));
newDict.Add("A", "y");
Console.WriteLine(newDict.ContainsKey("a"));
Console.WriteLine(newDict.ContainsKey("A"));
Console.WriteLine(newDict.Count);
}
}
This outputs:
True
False
True
True
2
Explanation:
- At first, key
a
is added. ContainsKey
is used to check whether keysa
andA
are found. Only the former is.- Then,
Add
is used to add keyA
. It does not complain, i.e. it does not think that key already exists. - In the end,
Count
is used to check for the total number of dictionary entries and it correctly outputs2
, namelyA
anda
.