【发布时间】:2020-05-06 12:10:47
【问题描述】:
我有这样的事情:
catch (Exception ex)
{
if (ex is "Exception Type")
{
}
else if (ex is SqlException)
{
}
else if
{
...
...
...
}
这在C# 中是否正确,is 到底是什么意思,这是它的作用还是有其他方式?
【问题讨论】:
-
你可以有多个 catch 块:
catch(MyException1 ex){...}catch(MyException2 ex){...} -
@GuruStron,怎么做?
标签: c# exception try-catch sqlexception catch-block