C#

C#

Made by DeepSource

var is redundant when combined with out and a discard pattern CS-R1067

Anti-pattern
Major
Autofix

The out keyword is used to indicate that the parameter is initialized by the method to which it is being passed. But, when a discard pattern (_) is used with out, it indicates that the variable is unused and is only a placeholder. Therefore, in such cases, the keyword var becomes redundant and can be dropped.

Bad Practice

dict.TryGetValue(key, out var _);

Recommended

dict.TryGetValue(key, out _);

Reference