Explicit Implementation

Sometimes it's necessary to explicitly declare which interface a class or struct member implements. One common reason for explicit implementation is when there is multiple interface inheritance and two or more interfaces declare a member with the same name. Another reason to use explicit interface implementation is to hide a specific implementation.

To perform explicit interface implementation, a class implements an interface member by using its fully qualified name. The implementation is not declared with modifiers, because they are implicitly hidden from an object of the implementing class. However, they are implicitly visible to objects of the explicit interface type. The examples in this chapter show how this occurs. ...

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.