Dispose method and IDisposable

  • Thread starter Thread starter Erik Cruz
  • Start date Start date
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
 
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
 
Back
Top