is it possible?
i want to get the name of class (like foo) which is invoking my method (like myMethod)
(and the method is in another class(like i))
like:
class foo
{
i mc=new i;
mc.mymethod();
}
class i
{
myMethod()
{........
Console.WriteLine(InvokerClassName);// it should writes foo
}
}
thanks in advance
You can use
StackTraceto work out the caller – but that’s assuming there’s no inlining going on. Stack traces aren’t always 100% accurate. Something like: