This C# Program Demonstrates Multilevel Inheritance. Here when a derived class is created from another derived class, then that inheritance is called as multi level inheritance.
Here is source code of the C# Program to Demonstrate Multilevel Inheritance. The C# program is successfully compiled and executed with Microsoft Visual Studio.
The program output is also shown below.
using System;
namespace demo
//Multilevel Inheritance in C#-Example
class Child2 : Child1
public Child2()
Console.WriteLine("Print from Child2 !!");
public void MethodFrmChild2()
Console.WriteLine("Print from MethodFrmChild2 !! ");
static void Main(string[] args)
var obj = new Child2();
obj.MethodFrmParent();
obj.MethodFrmChild1();
obj.MethodFrmChild2();
Console.Read();
class ParentClass
public ParentClass()
Console.WriteLine("Print from Parent!!");
public void MethodFrmParent()
Console.WriteLine("Print from MethodFrmParent!!");
class Child1 : ParentClass
public Child1()
Console.WriteLine("Print from Child1 !!");
public void MethodFrmChild1()
Console.WriteLine("Print from MethodFrmChild1!!");
Output
Print from Parent!!
Print from Child1 !!
Print from Child2 !!
Print from MethodFrmParent!!
Print from MethodFrmChild1!!
Print from MethodFrmChild2 !!
Multilevel Inheritance in C#-Example
No comments:
Post a Comment