Implementing an Interface

phrase

say it: “IM-pluh-ment-ing an IN-ter-fays” /ˈɪmplɪmɛntɪŋ ən ˈɪntərfeɪs/

A class keeping an interface's promise by writing every member the interface lists.

What does implementing an interface mean in C#?

Implementing an Interface — A class keeping the promise an interface makes: it names the interface after its colon and writes a public version of every member the interface lists. The compiler refuses the class until every member is there.

interface IShippable { decimal ShippingCost(); }

class Book : IShippable
{
    public decimal ShippingCost() => 3.99m;
}

In a sentence

  • “By implementing an interface, IShippable, Book promises a ShippingCost method.”

Level: Journeyman · More C# terms at this level

Updated