I've got a simple question that my mind is drawing a blank to: I have a Dictionary that looks something like this:
Dictionary<string, Dictionary<string, string>> dict;
As far as I know, dict.Remove() would remove any entry by key, but I need to only remove an item from the innermost dictionary. How would I go about that?
Well presumably you've got two keys: one for the outer dictionary and one for the nested one.
So assuming you know that the entry is present, you can use
dict[outerKey].Remove(innerKey);
If you don't know whether the entry exists, you want something like:
Dictionary<string, string> innerDict;
if (dict.TryGetValue(outerKey, out innerDict))
{
// It doesn't matter whether or not innerKey exists beforehand
innerDict.Remove(innerKey);
}
See more on this question at Stackoverflow