Sagaert,
No, you can't. Here is why. Suppose you have a method which relies on
this, called GetVariableName, then what happens when you do this?
Myclass myvar = new Myclass();
Myclass myvar2 = myvar;
myvar.GetVariableName();
The problem is that myvar and myvar2 reference the same thing, so there
are two variables (there can be an unlimited number, or none, really,
because your instance might be ready for a GC).
What are you trying to do?
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Sagaert Johan" <RE*************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi
Consider the following :
Myclass myvar=new Myclass ();
is there a way to get the name of the instance of the variable inside the
class ?
so i know in my class that the variables name is myvar ?
Can this be done through reflection ?
Johan