How to get variable name using reflection?

Posted by Eran Betzalel on Stack Overflow See other posts from Stack Overflow or by Eran Betzalel
Published on 2010-04-02T10:14:12Z Indexed on 2010/04/02 10:33 UTC
Read the original article Hit count: 324

Filed under:
|

For example,

static void Main()
{
    var someVar = 3;

    Console.Write(GetVariableName(someVar));
}

The output of this program should be:

someVar

How can I achieve that using reflection?

© Stack Overflow or respective owner

Related posts about c#

Related posts about reflection