ReSharper 2026.1 Help

Code inspection: Variable in local function hides variable from outer scope

This inspection reports a local variable or parameter declared in an inner scope when it hides a variable from an outer scope. Reusing the same name in nested local functions or lambdas can make it unclear which variable the code is reading or modifying.

Example

void M() { int value = 1; void Local() { int value = 2; Console.WriteLine(value); } }
void M() { int value = 1; void Local() { int localValue = 2; Console.WriteLine(localValue); } }

Quick-fix

Rename the inner variable to avoid hiding the outer variable.

01 April 2026