Constructor Chaining in C sharp with program

using System;

class employee
{

string message;
public employee()
{

}
public employee(string mess)
{
message = mess;

}
public void displayME()
{
Console.WriteLine(message);
}
}

class manager:employee
{
string message;
public manager()
{

}
public manager(string m) :base(m)
{
message = m;
}

public void displayM()
{
Console.WriteLine(message);
}
public static void Main()
{
manager deepa = new manager(“leave for two days”);
deepa.displayM();
deepa.displayME();

}
}

OUTPUT:

leave for two days

leave for two days

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.