CSharp - Interface Interface Extending

Introduction

Interfaces can inherit from other interfaces.

For instance:

interface Printable{ 
   void Print(); 
}
interface Formattable : Printable { 
   void Format(); 
}

Formattable "inherits" all the members of Printable.

Types that implement Formattable must also implement the members of Printable.

The following code shows how to extend interface.

Demo

using System;

interface Interface1
{
    void ShowInterface1();
}
interface Interface2
{
    void ShowInterface2();
}
//Interface implementing multiple inheritance
interface Interface3 : Interface1, Interface2
{
    void ShowInterface3();
}
class MyClass : Interface3
{
    public void ShowInterface1()
    {/*w  ww .  j  ava  2  s  .  c o  m*/
        Console.WriteLine("ShowInterface1() is completed.");
    }

    public void ShowInterface2()
    {
        Console.WriteLine("ShowInterface2() is completed.");
    }

    public void ShowInterface3()
    {
        Console.WriteLine("ShowInterface3() is completed.");
    }
}

class Program
{
    static void Main(string[] args)
    {
        MyClass myClassOb = new MyClass();
        Interface1 ob5A = myClassOb;
        ob5A.ShowInterface1();

        Interface2 ob5B = myClassOb;
        ob5B.ShowInterface2();

        Interface3 ob5C = myClassOb;
        ob5C.ShowInterface3();
    }
}

Result