【发布时间】:2013-08-23 12:09:56
【问题描述】:
通过下面的代码
示例:
try
{
//some code is executing..
//1.some SqlException thrown
//2.some FormatException thrown
//3. other Exception thrown
}
catch(SqlException sqlex)
{
Console.WriteLine("sqlexception is returned");
}
catch(FormatException fx)
{
Console.WriteLine("FormatException is returned");
}
catch(Exception ex)
{
Console.WriteLine("Mainexception is returned");
}
catch
{
Console.WriteLine("exception without any args is returned");
}
这可能是什么输出,为什么?
首先执行哪个 catch 块,为什么?
1234563带参数 System.Exception 充当主异常或主要异常块..?如果是这样,为什么..?
请提前告知并感谢您的帮助。
【问题讨论】:
-
MSDN 上有很好的描述:Using Exceptions 和Exceptions and Exception Handling 中的其他几个主题
标签: asp.net .net c#-4.0 exception-handling