var
is redundant when combined with out
and a discard pattern CS-R1067The 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.
dict.TryGetValue(key, out var _);
dict.TryGetValue(key, out _);