Why does ConcurrentDictionary.TryRemove require a second out argument?

C#7 added discard syntactic sugar

So now you can write:

dictionary.TryRemove(entry.Key, out _); 

Reference

We allow “discards” as out parameters as well, in the form of a _, to
let you ignore out parameters you don’t care about:

p.GetCoordinates(out var x, out _); // I only care about x

Leave a Comment