6.6. Implementing interfaces

Interfaces, though new to C++ developers, is already a well-used and well-understood concept in the Java world. The idea of interfaces in C# is the same as for Java, except for the minor differences described below.

To implement one or more interfaces, use the following syntax when declaring your class:

class <class_name>:<interface1>[,<interface2>,<interface3>...]

Like Java

  • C# does not support multiple class inheritance, but it does allow a class to implement multiple interfaces. [11]

    [11] We can say that both Java and C# support multiple interface inheritance, but only single implementation inheritance. Though it can be confusing to use the term 'inheriting an interface' instead of 'implementing an interface', ...

Get From Java to C#: A Developer's Guide 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.