faqts : Computers : Programming : Languages : C#

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

8 of 13 people (62%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

C#: How to use the 'this' command in C#?

Dec 12th, 2003 15:40
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 25 September 2003 - 06:56 pm ------------------

C#: How to use the 'this' command in C#?

---

Using the 'this' keyword

---

To tell the compiler which variable names correspond to class members
and which variable names correspond to method parameters, precede the 
class
member variable names with the 'this' keyword, as shown here:

---

public CLASSAddres( string nameS, string streetS, string cityS ) {

 this.nameS = nameS; // so you inform to assign the parameter 'nameS' 
to the class variable 'nameS'

 this.streetS = streetS; // so you inform to assign the 
parameter 'streetS' to the class variable 'streetS'

 this.cityS = cityS; // so you inform to assign the parameter 'cityS' 
to the class variable 'cityS'

}

---
---

Internet: see also:

---

C++: How to use the 'this' command in C++?
http://www.faqts.com/knowledge_base/view.phtml/aid/16106

---

Delphi: How to use the 'this' command (='self') in Delphi?
http://www.faqts.com/knowledge_base/view.phtml/aid/16108/fid/175

---

Java: How to use the 'this' command in Java?
http://www.faqts.com/knowledge_base/view.phtml/aid/16104

---

Visual Basic: How to use the 'this' command (='Me') in Visual 
Basic.NET?
http://www.faqts.com/knowledge_base/view.phtml/aid/27372/fid/1610

---

C#: Keywords: Which are the C# keywords?
http://www.faqts.com/knowledge_base/view.phtml/aid/24772/fid/1086\

----------------------------------------------------------------------