C# Program to Demonstrate Abstract Class With Multiple-Level Inheritance

Today we are going to discuss this important topic via this article C# Program to Demonstrate Abstract Class With Multiple-Level Inheritance. We hope you like this article.

C# Program to Demonstrate Abstract Class With Multiple-Level Inheritance

C# Program to Demonstrate Abstract Class With Multiple-Level Inheritance

//C# program to demonstrate abstract class 
//with multi-level inheritance

using System;

abstract class Abs
{
    //Method Declaration
    public abstract void Method1();
}

class Sample1 : Abs
{
    //Method definition
    public override void Method1()
    {
        Console.WriteLine("Method1() called");
    }
}

class Sample2 : Sample1
{
    //Method definition
    public void Method2()
    {
        Console.WriteLine("Method2() called");
    }
}

class Sample3 : Sample2
{
    //Method definition
    public void Method3()
    {
        Console.WriteLine("Method3() called");
    }
}

class Program
{
    public static void Main(String[] args)
    {
        Sample3 S = new Sample3();

        S.Method1();
        S.Method2();
        S.Method3();
    }
}
Method1() called
Method2() called
Method3() called
Press any key to continue . . .

Final Words

C# Program to Demonstrate Abstract Class With Multiple-Level Inheritance We learned about this very clearly through this article. And if you liked this article please share it with your friend.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment