怎么样才能得到当前运行函数的名字。用来捕捉出现异常的这个方法(事件)用反射可以吗?
大侠帮忙!!

解决方案 »

  1.   

    我也一至在找
    应该和系统中的栈有关java 是可以的
      

  2.   

    Class1 myClass = new Class1();
    try 
    {
        myClass.MyMethod();
    }
    catch (Exception) 
    {
                    // Display file and line information, if available.
        StackTrace st = new StackTrace(new StackFrame(true));
        Console.WriteLine(" StackTrace: " + st.ToString());
        Console.WriteLine(" Line Number : " +
                st.GetFrame(0).GetFileLineNumber().ToString());
        Console.WriteLine("-------------------------------------------------\n");
    }