Duplicate
What is the best practice case of referencing "this" in any given class?
Basic C# Forms example:
class SomeForm : Form
{
public SomeForm() {
Text= "Hey, I'm a new form.";
Size= new Size(400,350);
SetupButtons();
}
private void SetupButtons() {
Button btn1= new Button();
//...
Controls.Add(btn1);
}
public static void Main() {
Application.Run( new SomeForm() );
}
}
vs:
class SomeForm : Form
{
public SomeForm() {
this.Text= "Hey, I'm a new form.";
this.Size= new Size(400,350);
this.SetupButtons();
}
private void SetupButtons() {
Button btn1= new Button();
//...
this.Controls.Add(btn1);
}
public static void Main() {
Application.Run( new SomeForm() );
}
}