Example of destructor In c#

Jitendrasoft09
Posted by Jitendrasoft09 under C# category on | Points: 40 | Views : 958
using System;

class MyClass {

public MyClass() {
Console.WriteLine("Constructor called");
}

~MyClass() {

Console.WriteLine("Destructor called");
}
}

class DestructorTest {

static void Main(string[] args) {


new MyClass();


GC.Collect();

Console.ReadLine();
}
}

Comments or Responses

Login to post response