tags:

views:

55

answers:

2

(very newbie questions)

i may be misunderstanding this but on MSDN i believe it says that it is good practice to implement the Dispose destructor in every class you write. should i (do you) really implement the IDisposable interface with every class i write?

also, is the proper syntax for implementing an interface to put the "Implements" keyword on the line after the "class" declaration? i put it on the same line as "class" and I got an error.

one more?: when coding the method implemented by the interface, is it mandatory to follow this syntax, as an example:

Public Sub Dispose() Implements System.IDisposable.Dispose

what i'm curious about in the above code, is if i need to declare the implemented method as "Implements System.IDisposable.Dispose"

+5  A: 

You should only implement IDisposable if your class holds instances of other classes that implement IDisposable, or if it holds native resources.

For more information, see this article.

SLaks
+2  A: 

No you should not. Only implement IDisposable if you are using unmanaged resources directly or have members that implement IDisposable and want to make sure their dispose method gets called when the dispose method gets called on your class.

Ben Robinson