取得实例类名称的字符串表示:
this.GetType().Name
取得当前运行的函数的名称 :
System.Reflection.MethodInfo.GetCurrentMethod().Name
或者
System.Diagnostics.StackFrame().GetMethod().Name
取得调用当前运行方法的方法的名称
System.Reflection;using System.Diagnostics;private static void WhoCallMe(){StackTrace stackTrace = new StackTrace();StackFrame stackFrame = stackTrace.GetFrame(1);MethodBase methodBase = stackFrame.GetMethod();Console.WriteLine( " Parent Method Name {0} \n", methodBase.Name ); }
转载于:https://www.cnblogs.com/harryhan1983/archive/2011/09/17/CurrentMethodName.html
相关资源:数据结构—成绩单生成器