0
Reply

Types that own disposable fields should be disposable

George George

George George

Jun 17 2008 1:59 AM
2.5k

Hello everyone,


For this best practices rule,

http://msdn.microsoft.com/en-us/ms182172.aspx

What are the benefits of following this rule even if I am not wrapping an unmanaged resource, like FileStream in the sample in the page.

I think it is fine if the class does not implement IDisposable, since FileStream could be disposed (to release the native file handle) since it has its own Dispose method. Any ideas?


thanks in advance,
George