是,有一点不同;
throw ex
重置堆栈跟踪(因此您的错误似乎源自HandleException
)throw
不会-原罪犯将得到保留。static void Main(string[] args)
{
try
{
Method2();
}
catch (Exception ex)
{
Console.Write(ex.StackTrace.ToString());
Console.ReadKey();
}
}private static void Method2()
{
try
{
Method1();
}
catch (Exception ex)
{
//throw ex resets the stack trace Coming from Method 1 and propogates it to the caller(Main)
throw ex;
}
}private static void Method1()
{
try
{
throw new Exception(“Inside Method1”);
}
catch (Exception)
{
throw;
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)