CHAPTER 17

image

Interface

An interface is used to specify members that deriving classes must implement. They are defined with the interface keyword followed by a name and a code block. Their naming convention is to start with a capital “I” and then to have each word initially capitalized.

interface IMyInterface {}

Interface signatures

The interface code block can only contain signatures, and only those of methods, properties, indexers and events. The interface members cannot have any implementations. Instead, their bodies are replaced by semicolons. They also cannot have any access modifiers since interface members are always public.

interface IMyInterface ...

Get C# Quick Syntax Reference 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.