ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Code inspection: Local variable hides member

Last modified: 11 February 2024

Having a local variable with the same name as a field effectively hides a member field. Here is an example:

This can lead to a confusing situation as someone might assume that the name they are referring to in the DoSomething() method is the field previously defined.