C# tip use Dictionary TryGetValue

dotnet C#

Here is another C# tip.
Most of the time when you are trying to get a value from dictionary you would try to check if the key exist or not something like.

But one can use TryGetValue

The benefit of using TryGetValue is that the dictionary is synchronized, there is no race condition.

Taswar Bhatti Avatar

Written by