【发布时间】:2010-12-18 01:43:54
【问题描述】:
在C#中有什么方法可以轻松实现以下伪代码:
try
{
...
}
catch ( ExceptionTypeA, ExceptionTypeB, ExceptionTypeC as ex)
{
... same code for all threw
}
或者
try
{
...
}
catch ( ExceptionTypeA ex )
catch ( ExceptionTypeB ex )
catch ( ExceptionTypeC ex )
{
... same code for all exceptions of A, B or C
}
我想我所说的会很好地解决异常类型。
【问题讨论】:
-
不能把通用代码提取到函数中?
-
也可以在这里查看解决方案:stackoverflow.com/questions/136035/…
标签: c# exception-handling