stupid question
I have been learning the C# language over the last month or two from the book Visual C# 2008 and was wondering what is the "this" keyword used for. I see it coming up over and over again in the book but it doesn't seem that they give a good definition of what it is used for.
Joe DoePosted Jul 12, 2008, 3:19 PM
Bechir BejaouiPosted Jul 12, 2008, 10:25 AM
example:
public class Person
{
/* The constructor the first method lunched after the object creation unsing new keyword */
public person(string FirstName, string LastName)
{
//The this here is used to refer the object it self, as you know
//the object person has a field called _FirstName and _LastName
this._FirstName;
this._LastName;
}
public string _FirstName;
public string _LastName;
}
in the other hand
Person me = new Person("Bejaoui","Bechir");
will define an object Person, in fact when me is created it invokes the Person(FirstName,LastName) then this or in this case me._FirstName<-FirstName
me._LastName<-LastName
Satish KathiPosted Jul 12, 2008, 12:05 AM
Refer this
http://msdn.microsoft.com/en-us/library/dk1507sz(VS.80).aspx