Monday, May 2, 2016

What is the difference between Finalize() and Dispose()?

Finalize()Dispose()
It belongs to the Object class.It belongs to the Idisposable interface.
It is slower method.It is faster method.
It is non-deterministic function, it means when Garbage Collector will call finalize() method to reclaim memory.It is deterministic function as Dispose() method is explicitly called by the User code.
It can be used to free unmanaged resources when you implement it like files, database connections etc. which is held by an object before that object is destroyed.It is used to free unmanaged resources like, files, database connections, etc. at any time.

No comments:

Post a Comment