C# Program to Implement Multiple Interfaces in the Same Class

You may have come across many doubts and confusions in the article. We guarantee that all your queries will be resolved via the C# Program to Implement Multiple Interfaces in the Same Class article.

C# Program to Implement Multiple Interfaces in the Same Class

C# Program to Implement Multiple Interfaces in the Same Class

//C# program to implement multiple interfaces 
//in the same class.

using System;

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

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

class Sample : MyInf1,MyInf2
{
    //Method definitions
    public void Method1()
    {
        Console.WriteLine("Method1() called");
    }
    public void 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

We hope the C# Program to Implement Multiple Interfaces in the Same Class article clears up your doubts and confusion. See you again in a good article. Thanks.

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