Illustrates a destructor : Destructor : Class Interface C# Source Code


Custom Search

C# Source Code » Class Interface » Destructor »

 

Illustrates a destructor









    

/*
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()");

  }

}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Class Interface
» Destructor