gpt4 book ai didi

c# - "Before the ` catch ` block is executed, the runtime checks for ` finally ` blocks.",什么意思?

转载 作者:行者123 更新时间:2023-12-05 03:02:23 25 4
gpt4 key购买 nike

来自 official document about the exception handling :

Before the catch block is executed, the runtime checks for finally blocks.

我觉得作者想说:“finally block 在catch block 之前执行”。

但这段代码的作用恰恰相反:

try
{
throw new Exception();
}
catch (Exception e)
{
Console.WriteLine("In the catch block.");
}
finally
{
Console.WriteLine("In the finally block.");
}
// Output:
// In the catch block.
// In the finally block.

这句话的真正含义是什么?

最佳答案

这是文档中的“错误”。该问题已提交 here .

适当的 catch block (如果有的话)在 相同 try-catch-finally 构造的潜在 finally block 之前执行。

关于c# - "Before the ` catch ` block is executed, the runtime checks for ` finally ` blocks.",什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54880401/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com