In the early days of my first object-oriented classes I was taught to use this
whenever it is a variable or class property.
Today I understand when there is a real need to use, for example when a parameter is received in the method that has the same name as a class variable:
private string algo;
public void FazerAlgo(string algo)
{
this.algo = algo;
}
Here answers this too, but that's not the question yet.
I noticed that Visual 2015 is now saying that using this
in situations other than the above is redundant. This did not happen in other versions as far as I remember.
As I see it, I always prefer to use this
, I think it gets more readable and I got used to it, but I had not tried until then because of the ambiguity, so I'm starting to change. For the question not to be subjective I ask:
Is there any reference / encoding standard that always recommends using this
from where my teacher might have taken it?