Get name of an object passed to function.

K

Ken Varn

Not sure if this is possible or not or if there is a better method for doing
this that I am not seeing. Anyhow, is there anyway to get the declared name
of an object that is passed to a function? See below:

public class TestClass
{
public String GetObjectName(Object O)
{
return // Want to be able to determine that O's declared name is
"MyString" as passed by TestFunc()
}
}

void TestFunc()
{
TestClass Test = new TestClass();
String MyString = "text";
String Name;

Name = Test.GetObjectName(MyString);
}

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
 
J

Justin Rogers

That won't be possible names such as MyString are locally symbolic
according to language rules and not globally symbolic across the
platform using the rules of the CLR. There is probably some probing
you could do backwards using the profiling API's to get the information
but it wouldn't be within the capacity of normal program operation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top