Destructors
cannot be defined in structs. They are only used with classes.
A
class can only have one destructor.
Destructors
cannot be inherited or overloaded.
Destructors
cannot be called. They are invoked automatically.
A
destructor does not take modifiers or have parameters.
class Person
{
~ Person()
{
Console.WriteLine("In Person Class Destructor");
}
}
class Employee : Person
{
~ Employee()
{
Console.WriteLine("In Employee Class Destructor");
}
}
class Program
{
static
void Main(string[]
args)
{
Employee
emp = new Employee();
// First Employee class destructor is called then
Person class destructor is called.
}
}
No comments:
Post a Comment