get the name of the method in C#

.net, c#, monitoring, trace

Solution

This will get you name -

string methodName = System.Reflection.MethodInfo.GetCurrentMethod().Name;

OR

string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;

Problem

Is there any way to get the name of the method that currently we are in it? ``` private void myMethod() { string methodName = __CurrentMethodName__; MessageBox(methodName); } ``` Like this.ToString() that returns the class name is there any possible way to get name of the method by something like monitoring or tracing the app?

Original source