【发布时间】:2014-04-16 17:17:01
【问题描述】:
换句话说,这两者有何不同?
try
{
// Something that can throw an error
}
catch
{
// Handle the error
}
finally
{
// Something that runs after the try statement
}
对比
try
{
// Something that can throw an error
}
catch
{
// Handle the error
}
// Something that runs after the try statement
【问题讨论】:
-
如果发现错误,最后使用。
-
你有没有尝试过没有catch的try-finally?
-
当使用 try 块时,无论是否发生异常,finally 块中的代码都保证运行。
-
这是一个明显的 RTFM 案例:msdn.microsoft.com/en-us/library/zwc8s4fz.aspx
-
您是否先通过 Google 搜索文档?
标签: c# javascript try-catch-finally