It's been covered fairly thoroughly by now in this context, but "this" is one of those keywords you may never have to use depending on your coding style. In my personal stuff, I don't decorate my member variables, so I end up using the keyword a lot, as it's typically advised *not* to mangle your parameter names just so you avoid typing "this". Parameters are part of your interface, and you want that as clean as possible. Typically, if you don't decorate your fields (for instance with m_*, or *_), the best name for that field is the one you probably call it in the first place, so why hunt for another?
There is however, another, more important (since there's not really any other way to do this one) application of the "this" keyword that I'm surprised hasn't been mentioned: self-returning. Very important for fluent interfaces. Some examples:
public class MyStringBuilder
{
//constructor and stuff
public MyStringBuilder Append(string newString)
{
//memory reallocation stuff -- probably push onto the end of a vector/list
//depending on language.
return this;
}
public string ToString()
{
//do stuff to turn our array into a string.
}
}
public class WidgetContainer
{
//fields and constructor and stuff
public WidgetContainer addCheckBox( /*parameters*/ )
{
widgets.add(new CheckBox( /*args*/ );
return this;
}
public WidgetContainer addRadioButton( /*parameters*/ )
{
widgets.add(new RadioButton( /*args*/ );
return this;
}
//et al.
}
//meanwhile... somewhere in main.
var sb = new MyStringBuilder();
sb.append("Hello").append(", ").append("World").append("!"); //a contrived example.
var wc = new WidgetContainer();
wc.addCheckBox(200,300).addCheckBox(200, 310).addCheckBox(200, 320).addButton(200, 330, "Start!", someCallbackFunctor);
EDIT: I had never seen those Extension Methods before... That's really cool.