Destructors : destructor « Class « C# / CSharp Tutorial






  1. A destructor method called just prior to an object's final destruction by the garbage collector.
  2. A destructor can be used to ensure that an object terminates cleanly.
  3. Destructors have this general form:
~class-name( ) {
// destruction code
}

class-name is the name of the class.









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