469,320 Members | 2,189 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,320 developers. It's quick & easy.

Obtaining sub/function name in runtime

Hello,

Is there a way to find during runtime the name of current sub or
function?

TIA

May 15 '06 #1
2 884
"yo***********@gmail.com" <yo***********@gmail.com> wrote:
Is there a way to find during runtime the name of current sub or
function?


Check out StackTrace and StackFrame classes in System.Diagnostics.
Beware of inlining, however, which may result in fewer stack frames than
you expect. Also, collecting stack frame information isn't the fastest
thing in the world, especially if you ship .PDBs and you want line and
file information too.

-- Barry
May 15 '06 #2
Great. I create a new object of type System.Diagnostics.StackFrame and
use its .GetMethod.Name.

Performence is not an issue since I use this for error logging only.

Thanks

May 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by amirmira | last post: by
11 posts views Thread by seannakasone | last post: by
9 posts views Thread by psujkov | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.