相关疑难解决方法(0)

Delphi中的C#/ Java"Try/Finally/Catch"等效构造

在Delphi中,你如何才能最终使用try,并一起使用?Java/C#等价物看起来像:

try {
    // Open DB connection, start transaction
} catch (Exception e) {
    // Roll back DB transaction
} finally {
    // Close DB connection, commit transaction
}
Run Code Online (Sandbox Code Playgroud)

如果你在Delphi中尝试这个,你可以使用try/finally或try/except; 但从来没有三个在一起.我想代码如下(不编译):

try
    // Open DB connection, start transaction
except on e: Exception do
begin
    // Roll back transaction
end
finally // Compiler error: expected "END" not "finally"
begin
    // Commit transaction
end
Run Code Online (Sandbox Code Playgroud)

delphi exception-handling

15
推荐指数
2
解决办法
4433
查看次数

标签 统计

delphi ×1

exception-handling ×1