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

Dispose() is called when we want to realese an unmanaged resources of an object.
finalize() also called for same but it doesn't assure object is garbage collected.
The dispose() method is defined inside the interface IDisposable whereas, the method finalize() is defined inside the class object.
The main difference between dispose() and finalize() is that the method 
dispose() has to be explicitly invoked by the user whereas, the method 
finalize() is invoked by the garbage collector, just before the object is destroyed.

Comments

Popular posts from this blog

Pagination of DataGrid in WPF using MVVM

Connect SQL Server Database to WPF Application and Perform CRUD Operations

Filter DataGrid and ListView in wpf using ICollectionView