To Use or Not To Use the 'this' qualifier in C#
Preferably, i use this
only to prevent ambiguity between (possibly) a property and a function parameter
public class thing
{
private string name;
public thing(string name)
{
this.name = name; // will set private string name to param string name
}
}
If you are already working in the context of a certain class, it's not so hard to keep this in mind, and i do not need to be reminded of the fact that I am addressing a local variable every time i address one.
So I think ReSharper's right on this one.
One of the important things to remember is that this
is removed by the compiler and so it is purely a matter of 'what looks good to you and those with whom you share code?'. It will affect performance not a whit.
I find it redundant particularly with a well defined coding standard:
Name // Property
_name // Member field
name // local variable
Using this.<whatever>
just seems to be more work.