How to extend interface by inheitance in C#

Interfaces Inheriting Interfaces

One interface can inherit another. The syntax is the same as for inheriting classes.


using System;/*  w w w  . ja  va 2 s  . co  m*/
interface Printable{
   void print();
}

interface Displayable:Printable{
   void output();
}

class MyClass : Displayable{
   public void print(){
     Console.WriteLine("print");
   }
   public void output(){
     Console.WriteLine("output");
   
   }
}

class Test
{
    static void Main()
    {

        Displayable cls = new MyClass();

        cls.print();
        cls.output();

    }
}

The output:





















Home »
  C# Tutorial »
    Custom Types »




C# Class
C# Struct
C# Interface
C# Inheritance
C# Namespace
C# Object
C# Delegate
C# Lambda
C# Event
C# Enum
C# Attribute
C# Generics
C# Preprocessor