name of current method

  • Thread starter Thread starter memememe
  • Start date Start date
M

memememe

How can I know what method I am currently on.
public void Hello(){
//some code that says, you are in method Hello()
}

the only solution I can come up with is creating an exception and getting
the stack trace and pasing the text, but that aint a pretty solution.
 
I'm not sure what you're after, but why can't you just write it out by hand?

for example:

public void Hello(){
Console.WriteLine("you are in method Hello()");
}
 
memememe,
Its easier to just create a new System.Diagnostics.StackFrame object, then
use the GetMethod method to find out where you are.

You may also want to review the System.Diagnostics.StackFrame class...

Hope this helps
Jay
 
How can I know what method I am currently on.
public void Hello(){
//some code that says, you are in method Hello()

Console.WriteLine ("You are in void Hello()");

Why would you want to generate that at runtime? It seems to me that
this would be a bigger cost than just litterally stating the
functionName
 
Back
Top