using System; using System.Diagnostics; namespace StackTraceTest { /// Class1 的摘要说明。 /// </summary> class Class1 { /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main(string[] args) { method2(); //输出method2 } static private void method1() { StackTrace st=new StackTrace(true); Console.WriteLine(st.GetFrame(1).GetMethod().Name.ToString()); } static private void method2() { method1(); Console.ReadLine(); } } } 相关文章: 2021-06-07 2021-07-04 2021-10-28 2022-12-23 2022-12-23 2021-09-03