谢谢

解决方案 »

  1.   

    堆栈信息里就有啊:
                try
                {
                    throw new Exception();
                }
                catch (Exception e)
                {                Console.WriteLine(e.StackTrace);
                }
      

  2.   

    被人抢先了不过还是详细说一下吧:
            static void Main(string[] args)
            {
                try
                {
                    int t = 1;
                    int i = 5 / --t;
                }
                catch (Exception e)
                {
                    int i = e.StackTrace.IndexOf("行号");
                    string s = e.StackTrace.Substring(i+3);
                    i = s.IndexOf(' ');
                    if (i != -1)
                    {
                        s = s.Substring(0, i);
                    }
                    //这里s已经存储了错误所在行号
                }
            }
      

  3.   

    http://msdn.microsoft.com/zh-cn/library/system.exception.stacktrace.aspx
      

  4.   

    输出e.toString 里面有
    不要截取字符串  根据VS版本会有不一样的显示
      

  5.   


    同意这位的意思, 如果是en版的.net 则需要截获:line的位置
      

  6.   

                try
                {
                    int t = 1;
                    int i = 5 / --t;
                }
                catch (Exception e1)
                {                System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace(e1,true);
                   int i= st.GetFrame(0).GetFileLineNumber();
                   int j = st.GetFrame(0).GetFileColumnNumber();
                   string k = st.GetFrame(0).GetFileName();
                }
      

  7.   

    StackTrace   st   =   new   StackTrace(new   StackFrame(true));   
    Console.WriteLine(st.ToString());   
    Console.WriteLine(st.GetFrame(0).GetFileLineNumber().ToString());   
      

  8.   

    虽然自己也经常try catch
    还没有怎么注意过呢,学习了