Try to search your question here, if you can't find : Ask Any Question Now ?

Is it really needed to implement dispose pattern for managed resources only

HomeCategory: stackoverflowIs it really needed to implement dispose pattern for managed resources only
Avatarjulie asked 4 months ago

I’ve read carefully through this article and it seems to clearly state that the dispose pattern should be implemented in all cases of IDisposable implementation. I’m trying to understand why I need to implement the dispose pattern in cases when my class holds only managed resources (i.e. other IDisposable members or safe handles). Why cannot I just write

class Foo : IDisposable
{
    IDisposable boo;

    void Dispose()
    {
        boo?.Dispose();
    }
}

if it’s definitely known that there are no unmanaged resources and there is no point to call Dispose method from finalizer as managed resources aren’t being freed from finalizer?

1 Answers
Best Answer
AvatarMatthias answered 4 months ago
Your Answer

17 + 17 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com