C# Remove item from nested dictionary -
i've got simple question mind drawing blank to: have dictionary looks this:
dictionary<string, dictionary<string, string>> dict;
as far know, dict.remove() remove entry key, need remove item innermost dictionary. how go that?
well presumably you've got 2 keys: 1 outer dictionary , 1 nested one.
so assuming know entry present, can use
dict[outerkey].remove(innerkey);
if don't know whether entry exists, want like:
dictionary<string, string> innerdict; if (dict.trygetvalue(outerkey, out innerdict)) { // doesn't matter whether or not innerkey exists beforehand innerdict.remove(innerkey); }
Comments
Post a Comment