Why use the "this" pointer here?

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);
}
 
K

Kevin Spencer

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.
 
B

bruce barker

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)
 
G

George Ter-Saakov

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top