Program to implement constructors and destructors in c#
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication30
{
class a
{
public int s, d;
public a()
{
Console.WriteLine("constructor--base class a");
}
~a()
{
Console.WriteLine("destructor--base class a");
}
public void display()
{
Console.WriteLine(s);
Console.WriteLine(d );
}
}
class b : a
{
public b()
{
Console.WriteLine("constructor--derived class b");
}
~b()
{
Console.WriteLine("destructor--derived class b");
}
}
}
class c:a
{
static void Main(string[] args)
{
b b1 = new b();
b1.d = 34;
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment