I have the follow code but it is awkward. How could I better structure it? Do I have to make my consuming class implement IDisposable and conditionally construct the network acc
Whatever is enclosed within the using statement will have it's IDispoable.Dispose
called as dictated by the IDisposable
interface. As seen on MSDN for using
...
Provides a convenient syntax that ensures the correct use of IDisposable objects.
Therefore if you put a custom type within the using
statement it should clean up its resources appropriately via the IDisposable
interface.