Reputation: 485
I am declaring a Dictionary inside a Dictionary like:
var something = new Dictionary<string, Dictionary<string, Object>>();
I want to be able to access both the outer dictionary as well as the inner dictionary with an IgnoreCase StringComparer.
var something = new Dictionary<string, Dictionary<string, Object>>(StringComparer.InvariantCultureIgnoreCase);
As I am only calling the constructor of the outer dictionary, how can I set the StringComparer of the inner dictionary? If I can't call it's constructor, I can see that there is a property Comparer
but I'm not sure how I can get access to the inner dictionary object instead of just a Key or Value.
Any suggestions?
Upvotes: 0
Views: 83
Reputation: 3070
When you declare:
var something = new Dictionary<string, Dictionary<string, Object>>();
It has not created any inner dictionary yet. You will initialize inner dictionary when you add data to it, e.g.
if(!something.ContainsKey("somekey"))
{
something["somekey"] = new Dictionary<string, Object>(StringComparer.InvariantCultureIgnoreCase);
}
Upvotes: 3