I would like to know if it is possible to remove an IDictionary
item by its key and in the same time get its actual value that has been removed?
Example
something like:
Dictionary<string,string> myDic = new Dictionary<string,string>();
myDic["key1"] = "value1";
string removed;
if (nameValues.Remove("key1", out removed)) //No overload for this...
{
Console.WriteLine($"We have just remove {removed}");
}
Output
//We have just remove value1
out removed
then contain?null
?default(T)
? – Jacobsennull
. – Reedydefault(T)
as with the TryXYZ pattern, but you're right it needs to be defined. – Carniola