Hi Rainer,
As other members have mentioned, generally for those classes that has
implemented the IDisposable interface, that means it will hold unmanaged
resources. And the class deisgner will provide the following means to let
those unmanaged resource be proper released:
** Let the user explicitlly call Dispose method to release the resource on
demand. This is most recommend since it will help make the resource be
released as earlier as possible.
** If the user doesn't call Dispose method, the Finalizer method of the
class(class designer should also put resource release code in it) will be
called when class instance be Garbage collected
So for your question, if the class is a well encapsulated one, you can
think that at GC time, the finalizer will help release those resource(just
like you call Dispose method). But manually call Dispose(if you know that
the resource is no longer needed) is always preferred.
BTW, if you have interests, you can use Reflector tool to inspect those
classes in .NET framework library which have implemented IDisposable
interface to get some further idea on this.
Hope this also helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.