Is there a way to remove an entry from a Dictionary (by Key) AND retrieve it\'s Value in \"the same step?\"
For example, I\'m
You can do it with an Extension method:
public static string GetValueAndRemove(this Dictionary dict, int key)
{
string val = dict[key];
dict.Remove(key);
return val;
}
static void Main(string[] args)
{
Dictionary a = new Dictionary();
a.Add(1, "sdfg");
a.Add(2, "sdsdfgadfhfg");
string value = a.GetValueAndRemove(1);
}