2008-10-15 42 views
1

以下代码片段基本上是否相同?抛出语义

catch(Exception E) { 
    ... 
    throw E; //Explicitly rethrow the exception 
} 

catch(Exception E) { 
    ... 
    throw; //Implicitly rethrow the exception 
} 

this question重复。

+0

请参见[此问题](http://stackoverflow.com/questions/22623/net-throwing-exceptions-best-practices) – Ray 2008-10-15 19:27:37

回答

4

NO。

catch(Exception E) 
{ 
    ... 
    throw E; //Explicitly rethrow the exception 
} 

这一个重新启动堆栈跟踪,而抛出保持堆栈跟踪并添加到它。

如果您要重新抛出异常使用抛出。