Multi Level Inheritance
using System;
// When a derived class is created from another derived class, then that inheritance is called as multi level inheritance.
class Class1
{
public void display1()
{
Console.WriteLine("display of Class1");
}
}
class Class2 : Class1 // Now Class2 contains all the public members of Class1 through single inheritance.
{
public void display2()
{
Console.WriteLine("display of Class2");
}
};
class Class3 : Class2 // Now Class3 contains all the public members of Class1 and Class2 through multilevel inheritance.
{
public void display3()
{
Console.WriteLine("display of Class3");
}
static void Main(string[] args)
{
Class3 c3 = new Class3();
c3.display1();
c3.display2();
c3.display3();
Console.ReadLine();
}
}
Output:
display of Class1
display of Class2
display of Class3