G
guifuli
Unregistered / Unconfirmed
GUEST, unregistred user!
一段程序如下:
function DoSomething: Integer;
var
i: Integer;
MS: TMemoryStream;
begin
MS := TMemoryStream.Create;
try
MS.LoadFromFile('C:/Temp/1.jpg');
for i := 0 to MS.Size do
begin
// Here do something with MS
if i > SomeValue then
Exit
// 问题在这里了,如果Exit后还会执行finally 后面的 MS.Free 语句吗?如果不能执行MS.Free,那么这里该怎么做呢?
end;
finally
MS.Free;
end;
end;
function DoSomething: Integer;
var
i: Integer;
MS: TMemoryStream;
begin
MS := TMemoryStream.Create;
try
MS.LoadFromFile('C:/Temp/1.jpg');
for i := 0 to MS.Size do
begin
// Here do something with MS
if i > SomeValue then
Exit
// 问题在这里了,如果Exit后还会执行finally 后面的 MS.Free 语句吗?如果不能执行MS.Free,那么这里该怎么做呢?
end;
finally
MS.Free;
end;
end;