C#获得调用方法的名称和类名


 public static string getFileName()
        {
            StackTrace trace = new StackTrace();
            StackFrame frame = trace.GetFrame(1);
            MethodBase method = frame.GetMethod();
            String className = method.ReflectedType.Name;


            return "ClassName:" + className + "\nMethodName:" + method.Name;


            //Console.Write("ClassName:" + className + "\nMethodName:" + method.Name);
        }

你可能感兴趣的:(window,C#,C#获得调用方法的名称和类名,c#)