State the differences between the Dispose() and Finalize(). Ans. CLR uses the Dispose and Finalize methods to perform garbage collection of run-time objects of .NET applications. The Finalize method is called automatically by the runtime. CLR has a garbage collector (GC), which periodically checks for objects in heap that are no longer referenced by any object or program. It calls the Finalize method to free the memory used by such objects. The Dispose method is called by the programmer. Dispose is another method to release the memory used by an object. The Dispose method needs to be explicitly called in code to dereference an object from the heap. The Dispose method can be invoked only by the classes that implement the IDisposable interface. - Study24x7
Social learning Network
27 Apr 2023 11:22 AM study24x7 study24x7

State the differences between the Dispose() and Finalize(). Ans. CLR uses the Dispose and Finalize methods to perform garbage collection of run-time objects of .NET applications. The Finalize method is called automatically by the runtime. CLR has a garbage collector (GC), which...

See more

study24x7
Write a comment
Related Questions
500+   more Questions to answer
Most Related Articles