Interface Inheritance Demo : Interface hierarchy « Class « C# / CSharp Tutorial






using System;

interface ITest {
    void Foo();
}

class Base : ITest {
    public void Foo() {
        Console.WriteLine("Base.Foo (ITest implementation)");
    }
}

class MyDerived : Base {
    public new void Foo() {
        Console.WriteLine("MyDerived.Foo");
    }
}

public class InterfaceInh3App {
    public static void Main() {
        MyDerived myDerived = new MyDerived();
        Console.WriteLine();

        myDerived.Foo();
        Console.WriteLine();

        ((ITest)myDerived).Foo();
    }
}








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