Illustrates a destructor : destructor « Class « C# / CSharp Tutorial






public class Car
{
  ~Car()
  {
    System.Console.WriteLine("In ~Car() destructor");
  }

}

class MainClass
{

  public static void Main()
  {
    Car myCar = new Car();

    System.Console.WriteLine("At the end of Main()");
  }

}
At the end of Main()
In ~Car() destructor








7.14.destructor
7.14.1.Destructors
7.14.2.Simple Finalize
7.14.3.Illustrates a destructor
7.14.4.Demonstrate a destructor.
7.14.5.Use destructor and implement IDisposable
7.14.6.Base destructor
7.14.7.Update static field in the deconstructor