What is purpose of dispose method

Total Post:135

C#  ASP.Net 
 1051  View(s)
Rate this:
Hi Everyone,
I want to know what is purpose of dispose method and which scenario we used? Can anyone give me a solution?
Thank you.
  1. Post:106

    Re: What is purpose of dispose method

     When we are  implementing a Dispose method in my application then it releases unmanaged resource used by my application. The .NET Framework garbage collector does not allocate or release unmanaged memory.

    The pattern for disposing an object, referred to as a dispose pattern, imposes order on the lifetime of an object. The dispose pattern is used only for objects that access unmanaged resources, such as file and pipe handles, registry handles, wait handles, or pointers to blocks of unmanaged memory. This is because the garbage collector is very efficient at reclaiming unused managed objects, but it is unable to reclaim unmanaged objects.

      Modified On Apr-11-2018 01:32:39 AM