What is Finalizer? Explain how to implement it.
It is a method that is executed when an object is garbage collected. It is similar in function to a destructor. It keeps the memory managed by taking appropriate an action against an object that is released or is no longer in use. It is called up internally on garbage collection.
protected override void Finalize()
{
try
{
//Cleanup all the resources
}
finally
{
base.Finalize();
}
}