Target chain

If I implement an object with IDisposable, should all the objects that own this object should implement it, even if they do not have other resources for release?

+5
source share
4 answers

Yes. You must get rid of them so that your member variables are properly configured.

Each time you encapsulate the IDisposable class, you must make your IDisposable class. In the Dispose method, you must use your encapsulated resources. In principle, treat them the same way as with your native resource.

+12
source

, , - Dispose "using". , , IDisposable.

, , .

+1

Yes, the owning class should implement IDisposable, but it does not need (should not) Finalizer (destructor).

+1
source

nop, they just need to use this class with the "using" statement to make sure that they properly manage this object, but these objects themselves do not need to implement IDisplosable

+1
source

All Articles