Get name of an object passed to function.

  • Thread starter Thread starter Ken Varn
  • Start date Start date
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
-----------------------------------
 
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.
 
Back
Top