Interfaces Members
An interface can contain the following members:
Methods
Events
Properties
Indexers
By default, all interface members are public. Interface members cannot be declared with the following modifiers:
abstract
protected
public
internal
private
virtual
override
static
This is because an interface member needs to be publicly accessible, so that it can be implemented by the respective class.
Interface Methods
As mentioned earlier, an interface method cannot have a body. Therefore, the method declaration always ends with a semicolon, as shown in the following example:
interface MyInterface { void SampleFunction(); }
→ For a detailed explanation of methods, see “Class Members,” p. 152
Interface Events, Properties, and Indexers
An interface ...
Get Special Edition Using C# 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.