Jon Jagger
jon@jaggersoft.com
Table of Contents 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Notes DownloadECMA-334 C# Language Specificationpreviousnextprevious at this levelnext at this level 8 Language Overviewprevious at this levelnext at this level 8.7 Classesprevious at this levelnext at this level 8.7.9 DestructorsA destructor is a member that implements the actions required to destruct an instance of a class. Destructors cannot have parameters, they cannot have accessibility modifiers, and they cannot be called explicitly. The destructor for an instance is called automatically during garbage collection. The example
using System;  
class Point  
{  
   public double x, y;  
   public Point(double x, double y) {  
      this.x = x;  
      this.y = y;  
   }  
   ~Point() {  
      Console.WriteLine("Destructed {0}", this);  
   }  
   public override string ToString() {  
      return string.Format("({0}, {1})", x, y);  
   }  
}  
shows a Point class with a destructor.
{ JSL }
Jagger Software Ltd
Company # 4070126
VAT # 762 5213 42
Valid HTML 4.01Valid CSS