Inheritance

Interfaces have the capability to inherit from each other. This makes it possible to create an abstract hierarchy of interfaces that support some domain. When interfaces inherit from each other, they inherit the contract of the interfaces above them. Also, interfaces can inherit multiply from other interfaces. The following example shows how one interface can inherit from another.

public interface IShareTrade
{
    decimal PricePerTrade
    {
        get ;
        set ;
    }

    event ChangeRegistrar PriceChange ;
}

public interface IBroker : IShareTrade
{
    string GetRating(string stock) ;

    decimal this[string StockName]
    {
        get ;
        set ;
    }
}

The IBroker interface inherits the PricePerTrade property declaration and the PriceChange event declaration from the IShareTrade ...

Get C# Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.