Difference between Finalize() and Dispose()?

 Posted by Rajni.Shekhar on 4/23/2012 | Category: ASP.NET Interview questions | Views: 4556 | Points: 40

Finalize() method called by garbage collector at runtime when an object is no longer referenced.

Dispose() method is called by the code exiplicitily to dispose any object when needed by the program such as if there are unmanaged objects like file handles or any com object which can not be disposed by garbage collector, can be diposed using Dispose() method of IDisposable interface.

You do not know when finalize method will be execute by garbage collector.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response