ReSharper 2017.2 Help

Code Inspection: Unused local variable

This inspection detects local variables in a method that are declared and may be assigned, but are never used. Such a variable might act only once as the recipient in an assignment statement, without read usages, for example:

public string ConvertValue(string newValue) { string s = newValue.ToLower(); // unused local variable return newValue.ToLower(); }

Unused variables increase code size and decrease performance. You should remove or use an unused local variable. ReSharper suggests removing it with the quick-fix Remove unused local variable.

ReSharper also offers an additional quick-fix — Indicate unused variable with name. You can select a meaningful name for it (_, dummy, or unused), to indicate that the variable is unused deliberately. With these names, ReSharper will not highlight the variable as unused.

Last modified: 12 October 2017