C# Program to Demonstrate the Inheritance of Interfaces

I hope every article can give you some new information. In that sense today we are going to know very clearly about C# Program to Demonstrate the Inheritance of Interfaces. Let’s go into our article.

C# Program to Demonstrate the Inheritance of Interfaces

C# Program to Demonstrate the Inheritance of Interfaces

//C# program to demonstrate the inheritance of interfaces

using System;

interface MyInf1
{
    //Method Declaration
    void Method1();
}

interface MyInf2:MyInf1
{
    //Method Declaration
    void Method2();
}

class Sample : MyInf2
{
    //Method definition
    void MyInf1.Method1()
    {
        Console.WriteLine("Method1() called");
    }

    void MyInf2.Method2()
    {
        Console.WriteLine("Method2() called");
    }

    
}

class Program
{
    public static void Main(String[] args)
    {
        MyInf1 M1;
        MyInf2 M2;

        M1 = new Sample();
        M2 = new Sample();

        M1.Method1();
        M2.Method2();
    }
}
Method1() called
Method2() called
Press any key to continue . . .

Final Words

C# Program to Demonstrate the Inheritance of Interfaces Article We hope you have all the information you need. Let me know if you have any doubts about this article. Thanks.

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

Share on:

Leave a Comment