using System;
namespace CsharpDestructor {
class Person {
public Person() {
Console.WriteLine("Constructor called.");
}
// destructor
~Person() {
Console.WriteLine("Destructor called.");
}
public static void Main(string [] args) {
//creates object of Person
Person p1 = new Person();
}
}
}
Output
Output
Constructor called.
Destructor called.