What are Finalizers - CSharp Custom Type

CSharp examples for Custom Type:Finalizer

Introduction

Finalizers are class-only methods that execute before the garbage collector reclaims the memory for an unreferenced object.

The syntax for a finalizer is the name of the class prefixed with the ~ symbol:

class Class1
{
  ~Class1()
  {
    ...
  }
}

Finalizers allow the following modifier:

Modifier Value
Unmanaged code modifier unsafe

Related Tutorials