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.
"Polaris" <etpolaris@.hotmail.com> wrote in message
news:#hTysNhAEHA.1600@.tk2msftngp13.phx.gbl...
> 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);
> }
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)
"Polaris" <etpolaris@.hotmail.com> wrote in message
news:#hTysNhAEHA.1600@.tk2msftngp13.phx.gbl...
> 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);
> }
And "Intelisense" is working.
George.
"bruce barker" <nospam_brubar@.safeco.com> wrote in message
news:OVy$4%23hAEHA.3308@.TK2MSFTNGP10.phx.gbl...
> 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)
> "Polaris" <etpolaris@.hotmail.com> wrote in message
> news:#hTysNhAEHA.1600@.tk2msftngp13.phx.gbl...
> > 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);
> > }
0 comments:
Post a Comment