C# Destructor

Destructors are used to destruct instances of classes. To create a destructor we need to create a method in a class with same name as class preceded with ~ operator so A destructor works opposite to constructor, It destructs the objects of classes.

Example :-

class Example1
{
    public Example1()
    {
        Console.WriteLine("Constructor");
    }

    ~Example1()
    {
        Console.WriteLine("Destructor");
    }
}