我正在为一位朋友审查一些代码,并说他在try-finally块中使用了一个return语句.即使try块的其余部分没有,Finally节中的代码是否仍会触发?
例:
public bool someMethod()
{
try
{
return true;
throw new Exception("test"); // doesn't seem to get executed
}
finally
{
//code in question
}
}
Run Code Online (Sandbox Code Playgroud)