c#和捕获异常

Ric*_*nks 4 c# exception

处理异常时附加常规异常catch是一种好习惯.一个例子可以使这个问题更清楚

try{
 // do something
}catch(spomespecificException1 ex){
 //logging and other stuff
}catch(spomespecificException2 ex){
 //logging and other stuff
}catch(Exception ex){
 //logging and other stuff
}
Run Code Online (Sandbox Code Playgroud)

我应该将异常catch附加到堆栈

Joh*_*ers 7

一般来说,你根本不应该抓住这些例外.不要捕获您实际上不知道如何处理的异常.

"处理"意味着修复.如果您无法解决问题,或者无法添加其他信息,则不要捕获异常.