When creating an element that implements IDisposable
, Dispose()
is called at the end of the using
block also if an exception is thrown, if I'm correct.
However, when creating a new element of ClassB
within the constructor of a disposable element, will the object of ClassB also be disposed if IDisposable
is implemented?
using (ClassA a = new ClassA(new ClassB()))
{
}
This may apply to classes that are related to Stream
. However, does this apply in general?