I am using ConcurrentDictionary
, and I need to remove elements using TryRemove
.
The implementation of TryRemove
requires an out parameter that returns the object that will be removed.
Body dummy;
if (!bulletBodies.TryRemove(bullet, out dummy))
{
}
...
I do not want to use an additional line on a dummy variable whenever I delete an entry in my dictionary: that's why I tried to circumvent the out return parameter unsuccesfully typing the horrors below. I also googled a bit, without success.
bulletBodies.TryRemove(bullet, null);
bulletBodies.TryRemove(bullet, out null);
bulletBodies.TryRemove(bullet, void);
...
Is there a way or a clever tip to manage unused out parameters, so there is no need to declare dummy variables anywhere?