Multi Level Inheritance

When we create a child class which inherited from another child class or in simple word if a class is created by using another child class then this type of implementation is called as Multilevel Inheritance.

In the above syntax, Class1 is the parent class of Class2, Class2 is the parent class of Class3. Now the relation between class1 and Class3 is, Class1 is the the Grand parent class of Class3 or Class3 is the Grand child class of Class1. This grand parent and grand child concept is nothing but Multi level inheritance.

CODE

EG 1 . Creating a class called Rectangle2D and inheriting to Rectangle3D class then creating a new class called Rectangle4D and inheriting Rectangle3D class

class Rectangle2D {
    public double length, width;
    public double Area() {
        return length * width;
    }
    public double Perimeter() {
        return 2 * (length+width);
    }
}

//Inheriting Rectangle2D to Rectangle3D
class Rectangle3D : Rectangle2D {
    public double height;
    public double Volume() {
        return length * width * height;
    }
}

//Inheriting Rectangle3D to Rectangle4D
class Rectangle4D : Rectangle3D {
    public void sampleMethod() {
        Console.WriteLine(length + width + height + Area() + Volume()) ;
    }
}