Hi,
Could I write a code that will get the method name within which the
code is written.
like I want
void showMethodName(){
string method;
method=Need a method here to get the method name which contains this
code. In this case it is "showMethodName"
}
Thanks
Chakravarti Mukesh
Ciaran O''Donnell - 13 Nov 2006 12:38 GMT
methodname = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
Ciaran O'Donnell
> Hi,
>
[quoted text clipped - 10 lines]
> Thanks
> Chakravarti Mukesh
Jon Skeet [C# MVP] - 13 Nov 2006 19:20 GMT
> Could I write a code that will get the method name within which the
> code is written.
[quoted text clipped - 5 lines]
> code. In this case it is "showMethodName"
> }
Ciaran showed you a way, but it should be noted that this is quite
expensive, and should almost always be avoided.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too