Article

From:
To:
Ralf Stocker
Subject:
Re: Delphi Project X Cross GUI
Newsgroup:
embarcadero.public.delphi.non-technical

Re: Delphi Project X Cross GUI

Brad White wrote:


> The reason that we have to use 'using' in C#
> is to make finalization deterministic.
> [...]
> In Delphi that is called Free.

	No. That's not right. The closest thing to Delphi's Free in C# is
IDisposable. The following code samples are more or less equivalent:

Delphi:
    foo = TFoo.Create;     foo.Bar;     foo.Free;
C#
    foo = new Foo();     foo.Bar();     foo.Dispose();
Neither one is robust. Better would be (again, these are sort of similar in what they do):
Delphi:
    foo = TFoo.Create;     try       foo.Bar;     finally       foo.Free;     end;
C#
    using (var foo = new Foo())     {         foo.Bar();     }
Like Rudy said, C#'s using is closer to Delphi's try/finally (though not the same).
-- Craig Stuntz __ Vertex Systems Corp. __ Columbus, OH Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz/
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Mon, 25 Nov 2024 11:34:48 UTC
Copyright © 2009-2024
HREF Tools Corp.