I have this class:
class Foo : IDisposable
{
SomeBigResource resource;
void UsingResource()
{
using(Bar bar = new Bar(SomeBigResource)
bar.doStuff();
}
void Dispose()
{
resource.Dispose();
}
}
void Function()
{
using (Foo foo = new Foo(new SomeBigResource))
foo.UsingResource();
}
The Bar object has exactly the same Dispose()
function.
Will my SomeBigResource
be released or is the GC smart enough to release it later on when the second using is done?