What is the difference between Dispose() and Finalize() ?
When the .NET framework instantiates an object, it allocates memory for that object on the managed heap. The object remains on the heap until it’s no longer referenced by any active code, at which point the memory it’s using is “garbage,” ready for memory deallocation by the .NET Garbage Collector (GC). Before the GC deallocates the memory, the framework calls the object’s Finalize() method, but developers are responsible for calling the Dispose() method. The two methods are not equivalent. Even though both methods perform object cleanup, there are distinct differences between them. The .NET garbage collector manages the memory of managed objects (native .NET objects) but it does not manage, nor is it directly able to clean up unmanaged resources. Managed resources are those that are cleaned up implicitly by the garbage collector. You do not have to write code to release such resources explicitly. In contrast, you must clean up unmanaged resources (file handles, database collections, e