Why use the "this" pointer here?

  • Thread starter Thread starter Polaris
  • Start date Start date
P

Polaris

I noticed in the ASP.NET web application, as shown below, the "this" pointer
is used in the code generated by the Visual C# IDE. Anyone can explain why
it is necessary to use the "this" pointer here? Thanks!

private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
 
I'm afraid that nobody CAN explain why it is necessary, because it is not.
On the other hand, it is not harmful.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
its a good coding practice as it explicitly sets the scope and prevents bugs

private void InitializeComponent()
{
bool Load = true; // hides member variable
this.Load += new System.EventHandler(this.Page_Load); // this uses
member variable because it fully specified
}

-- bruce (sqlwork.com)
 
And "Intelisense" is working.

George.


bruce barker said:
its a good coding practice as it explicitly sets the scope and prevents bugs

private void InitializeComponent()
{
bool Load = true; // hides member variable
this.Load += new System.EventHandler(this.Page_Load); // this uses
member variable because it fully specified
}

-- bruce (sqlwork.com)
 
Back
Top