Showing posts with label finalize. Show all posts
Showing posts with label finalize. Show all posts

Sunday, September 16, 2007

Finalize vs Dispose

In my opinion the difference between "Finalize" and "Dispose":

  • Finalize is always called by the GC, so we could never determine when this would happen.
  • Finalize cannot be overriden or called.
  • In order to use Dispose(), the class should impelement the IDisposable interface.
  • Dispose() is the right place for freeing up unmanaged resources like DB connection, handles, etc...
  • Dispose() is called when using the "using" block.