Depth indicates the Backtracking depth of the method.
For example, if method A calls Method B and method B calls getcurrentmethodfullname (2), the result is the full name of method A (namespace + class name + method name)
To obtain the current method, the value of depth must be 0.
Internal static string getcurrentmethodfullname (INT depth)
{
Try
{
Stacktrace ST = new stacktrace ();
String methodname = ST. getframe (depth). getmethod (). Name;
String classname = ST. getframe (depth). getmethod (). declaringtype. tostring ();
Return classname + "." + methodname;
}
Catch
{
Return NULL;
}
}
If you do not need to know the method call chain, you can use methodbase. getcurrentmethod () to get the current method. You can use name to get the name and declaringtype. tostring () to get the namespace and class names.
Methodinfo method = (methodinfo) methodbase. getcurrentmethod ();