Phi*_*ter -2 c# exception-handling return try-catch
我有这段代码:
try{
this.connection.Open();
cmd.ExecuteScalar();
return true;
}
catch(Exception exc){
throw exc;
}
finally{
this.connection.Close();
}
Run Code Online (Sandbox Code Playgroud)
我知道如果catch抛出异常,该finally块将继续运行.
但是回归try呢?
如果try块返回true,finally块会关闭我的连接吗?
这样安全吗?