Destructors

D

DaveL

Hello
Ive been Reading lots about constructions and iDisposable , i also implement
IDisposable in places...

But all The examples ive Seen abut destructors
only show the order of Execution base on inheritance

What Kind of Code and I place in a Destructor

DaveL
 
D

daveL

thank you
Pete
DaveL

Peter Duniho said:
A "destructor" in C# is simply a way to implement a "finalizer". The only
code you should put in a finalizer is as a backup to your IDisposable
implementation. See MSDN's documentation for more details:
http://msdn.microsoft.com/en-us/library/b1yfkh5e.aspx

Keep in mind that the finalizer is _only_ for backup management of
resources. There's no guarantee that it will be called at all, never mind
_when_. You should always be calling Dispose() explicitly for objects
that implement IDisposable, and if you do it correctly, no finalizer will
ever actually execute.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top