我正在查看一个朋友的一些代码,并说他在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
}
}
绝地无双
PIPIONE
慕尼黑的夜晚无繁华
随时随地看视频慕课网APP