class ClassA
{
public ClassA()
{
Console.WriteLine("Creating ClassA");
}
~ClassA()
{
Console.WriteLine("Destroying ClassA");
}
}
class ClassB : ClassA
{
public ClassB()
{
Console.WriteLine("Creating ClassB");
}
~ClassB()
{
Console.WriteLine("Destroying ClassB");
}
}
class ClassC : ClassB
{
public ClassC()
{
Console.WriteLine("Creating ClassC");
}
~ClassC()
{
Console.WriteLine("Destroying ClassC");
}
}
class Mehul
{
public static void Main ()
{
ClassC c = new ClassC();
Console.WriteLine("Press enter to Destroy Object");
Console.ReadLine();
c = null;
GC.Collect();
Console.ReadLine();
}
good one mehul..it will be good if u print the values also
ReplyDelete