I'm probably contrarian on this (pun intended), but I generally use
"this." explicitly for references to member fields, because it helps to
distinguish fields from variables. To me, it's just a way to make code
more self-evident. I don't like coming across a reference and having to
waste cycles figuring out / remembering if it's a field or not.
I don't bother doing this with methods, however, because there is no
need to distinguish whether a method is in the current class or not.
Inherently, a method call to another class is prefixed with an instance
variable, so any method call that's not thusly prefixed is part of the
current hierarchy scope.
When it comes to static methods, I always use the class prefix even if
I'm calling a static method from an instance method in the same class;
again, just to make the code more self-evident.
The operative principle here IMO is that it's harder to read code than
to write code. So make it easy to read. You save time and effort in
the long run.
--Bob
Dom wrote:
Can I have a consensus. Is it common to start every variable,
control, etc, with "this"? I tend to do it, because I like the
Intellisense window. But is it considered amaturish?
Told you it was a simple question.