I only want to remove a value.. I don\'t need to use the variable afterwards. Why not include an overload where this second parameter was not required?
Do I really h
If you're not interested in the value that was removed, simply call IDictionary.Remove(key)
. It's shadowed, so you have to invoke it explicitly.
Example:
var dict = new ConcurrentDictionary();
dict.AddOrUpdate("mykey", (val) => "test", (val1, val2) => "test");
((IDictionary)dict).Remove("mykey");
The TryRemove(key, out value)
method is there to give you feedback whether the operation made any change. Use the one that best suits your needs.