p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   C# (http://p2p.wrox.com/forumdisplay.php?f=22)
-   -   this keyword (http://p2p.wrox.com/showthread.php?t=7393)

RSteel December 18th, 2003 03:13 AM

this keyword
 
I understand the concept of delegates and events, but I guess I'm just a bit foggy on when I should be using the "this" keyword.

I understand that we use this with current object instances but why and how exactly should I use it? Can someone please offer a better explaination? I have followed the examples in the Beginning Visual C# book but am still fuzzy on it. Thanx.

Sincerly,
Raymond Bohnenstiehl


jacob December 18th, 2003 04:33 AM

You can use the keyword, when you explicitly want to say that it is the instance in the object that you mean, like in...
Code:

private string variable;
public void someFunction(string variable)
{
    this.variable = variable;
}

(within a class).

Hope it helps.

Jacob.



All times are GMT -4. The time now is 02:47 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.