Articles of level

Intermediate

Finalizers

Finalizers are special methods that are automatically called by the GC before the object is collected. They can only be called by the GC provided they exist. The .NET ultimate base class Object has a Finalize method that can be overridden by child objects (anyone basically). The purpose of finalizers is to ensure all unmanaged resources the object may be using are properly cleaned up prior to the end of the object lifetime.
If a type has an implemented (overridden) finalizer at the time of collection, the GC will first put the object in the finalization queue, then call the finalizer and then the object is destroyed.Finalizers are not directly supported by C# compilers; instead you should use destructors using the ~ character, like so:

Need Help? Contact Us.

Log in

*
*

Forgot password?

*

New User

*
*
*
*