通常我会这么做:
try
{
code
code that might throw an anticipated exception you want to handle
code
code that might throw an anticipated exception you want to handle
code
}
catch
{
}
这样做有什么好处吗?
code
try
{
code that might throw an anticipated exception you want to handle
}
catch
{
}
code
try
{
code that might throw an anticipated exception you want to handle
}
catch
{
}
code
更新:
我最初问这个问题是关于 C # 的,但是正如 A。 Levy 所说,它可以应用于任何异常处理语言,所以我让标签反映了这一点。