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.
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
Post a Comment