可能重复:
一次捕获多个异常?
在C#中有什么方法可以轻松实现以下pseduo代码:
try
{
...
}
catch ( ExceptionTypeA, ExceptionTypeB, ExceptionTypeC as ex)
{
... same code for all threw
}
Run Code Online (Sandbox Code Playgroud)
要么
try
{
...
}
catch ( ExceptionTypeA ex )
catch ( ExceptionTypeB ex )
catch ( ExceptionTypeC ex )
{
... same code for all exceptions of A, B or C
}
Run Code Online (Sandbox Code Playgroud)
我想我所说的将是很好的将在异常类型上落空.