标签:
try
{
int t = 1;
int i = 5 / --t;
}
catch (Exception ee)
{
int i = ee.StackTrace.IndexOf("行号");
string s = ee.StackTrace.Substring(i + 3);
i = s.IndexOf(‘ ‘);
if (i != -1)
{
s = s.Substring(0, i);
}
}
int exceptionLine = Convert.ToInt32(s);//错误行号
此方法只适合中文状态查找!如果有更好的方法,欢迎留言。
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://www.cnblogs.com/iZander/p/4795395.html