Dispose,

C

cronusf

I have a managed class that contains objects that implement
IDisposable. So my class also implements IDisposable, and simply
calls the Dispose method for each object:

public void Dispose()
{
mMovieAVI.Dispose();
mMovieRT.Dispose();
}

Since my class doesn't contain any unmanaged resources directly, am I
correct that I do not need a finalizer?
 
N

Nicholas Paldino [.NET/C# MVP]

If the class was marked as sealed, then I would say yes, this is fine.

If it is not sealed, then you should implement it the way suggested here
(for the base class, assuming this is the first class in the hierarchy that
implements IDisposable) so that classes that derive from yours have a chance
to hook into the dispose call chain:

http://msdn.microsoft.com/en-us/library/b1yfkh5e.aspx
 

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