From within a method of a class, how do you determine the
name of the class.method that called it, programmatically?
I have a log file class, and it would be very beneficial
to be able store the name of the class and method that
called my LogFile.Write method.
Kind regards
Ben
Christopher Wells - 23 Jul 2004 16:33 GMT
> From within a method of a class, how do you determine the
> name of the class.method that called it, programmatically?
Perhaps the System.Diagnostics.StackTrace class is what you want.
Sridhar - 23 Jul 2004 22:00 GMT
Hi,
May be You can use
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType which will give the class name from which it is called.
Sridhar!!
> From within a method of a class, how do you determine the
> name of the class.method that called it, programmatically?
[quoted text clipped - 6 lines]
>
> Ben
Ahmed AbouTaleb - 26 Jul 2004 17:01 GMT
You can use System.Diagnostics.StackTrace to get the calling method using
GetFrame method.