Saturday, November 7, 2009

Example program FOR Destructor

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication12
{
class A
{
public A()
{
Console.WriteLine("creation A");
}
~A()
{
Console.WriteLine("destroying A");
}
}
class B : A
{
public B()
{
Console.WriteLine("creation B");
}


~B()
{
Console.WriteLine("destroying B");
}
}
class C : B
{
public C()
{
Console.WriteLine("creation C");
}

~C()
{
Console.WriteLine("destroying C");
}
}
class MainClass
{
public static void Main()
{
C c = new C();
Console.WriteLine("object created");
Console.WriteLine("press enter to destroy");
c = null;
Console.ReadLine();
}
}

}

No comments:

Post a Comment