Dispose method and IDisposable

E

Erik Cruz

Hi.

When implementing a Dispose method for a class, is it enough to create a
method called Dispose, or is it mandatory to implement the IDisposable
interface on the class?

Thanks,

Erik Cruz
 
J

Jon Skeet

Erik Cruz said:
When implementing a Dispose method for a class, is it enough to create a
method called Dispose, or is it mandatory to implement the IDisposable
interface on the class?

It would be a very good idea to implement IDisposable:

o It makes it clear that instances of your class *should* be disposed
o It allows users of C# to use the "using" construct
 

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