Interfaces Inheriting Interfaces : Interface hierarchy « Class « C# / CSharp Tutorial






using System;

interface Getter
{
   int GetData();
}

interface Setter
{
   void SetData(int x);
}

interface GetterAndSetter : Getter, Setter
{
}

class MyData : GetterAndSetter
{
   int data;

   public int GetData()
   {
      return data;
   }

   public void SetData(int x)
   {
      data = x;
   }
}

class MainClass
{
   static void Main()
   {
      MyData data = new MyData();
      data.SetData(5);
      Console.WriteLine("{0}", data.GetData());
   }
}
5








7.33.Interface hierarchy
7.33.1.Interfaces Based on Interfaces
7.33.2.Interface Inheritance Demo
7.33.3.Interfaces Inheriting Interfaces
7.33.4.One interface can inherit another.
7.33.5.Inheritance from both class and interface