Illustrates a destructor

image_pdfimage_print

   

/*
Mastering Visual C# .NET
by Jason Price, Mike Gunderloy

Publisher: Sybex;
ISBN: 0782129110
*/
/*
  Example5_14.cs illustrates a destructor
*/


// declare the Car class
class Car
{

  // define the destructor
  ~Car()
  {
    System.Console.WriteLine("In ~Car() destructor");
    // do any cleaning up here
  }

}


public class Example5_14
{

  public static void Main()
  {

    // create a Car object
    Car myCar = new Car();

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

  }

}