Re: What is "this" ?
- From: "Wessel Troost" <nothing@xxxxxxxxxxxx>
- Date: Sun, 10 Apr 2005 12:31:28 +0200
Normally, you don't need "this", as C# prefixes "this." by default.
However, say you have a member variable and a local variable with the
same name:
class TheUseOfThis : IUntestedExample
{
private string a;
public void MyFunction()
{
string a;
this.a = "assigned to member var";
a = "assigned to local var";
}
}
As you can see you need this to assign to the member variable.
There is no that in C#, of course.
Greetings,
Wessel
-----Original Message-----
From: WJ [mailto:JohnWebbs@xxxxxxxxxxx]
Posted At: Sunday, April 10, 2005 3:50 AM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: What is "this" ?
Subject: What is "this" ?
What is "this" that is being used by many asp and asp.net web
applications
and is there "that" object some where ? Googled what is that and was not
satisfied @ all !
I know for sure that in c#, I donot need "this" and the thing still
works
correctly as expected ! Is there a very good reason to use "this"
notation
on every line ?
John
.
- Follow-Ups:
- Re: What is "this" ?
- From: WJ
- Re: What is "this" ?
- References:
- What is "this" ?
- From: WJ
- What is "this" ?
- Prev by Date: Re: my namespace wont reference!
- Next by Date: Re: Separate Webserver and SQL Server -- error when connecting asp.net app to a database
- Previous by thread: Re: What is "this" ?
- Next by thread: Re: What is "this" ?
- Index(es):
Relevant Pages
|