Tuesday, July 2, 2013

What is finalization in .Net C#?

Finalization is to release native resources.
Finalization is a mechanism offered by the CLR that allows an object to perform some graceful cleanup prior to the garbage collector reclaiming the object’s memory. Any type that wraps a native resource, such as file, network connection, socket, mutex or other type, must support finalization. Basically, the type implements a method named Finalize.
When the garbage collector determines that an object is garbage, it calls the object’s finalize method (if exists). In other words, any type that implements the Finalize method is in effect stating that all of its object want a last meal before they are killed.


No comments:

Post a Comment