Saturday, 17 December 2016

Finalize vs Dispose in C#

Finalize() is called by Garbage Collector to free unmanaged resources.The garbage collector calls this method at some point after there are no longer valid references to the object.

some resources like windows handles,database connections which cannot be collected by the
garbage collector.Therefore the programmer needs to call Dispose() method of IDisposable interface.

Dispose() of IDisposable interface is called by the programmer to explicitly release resources when they are no longer being used.Dispose() can be called even if other references to the object are alive.

No comments:

Post a Comment