Default implementation of interface members
We have already learned that interfaces are used to define a contract that every implementing type must fulfill. Every interface member defines a portion of the contract by specifying a name and its signature (input and output parameters). The implementation (or body) of the defined members are then provided by the concrete types implementing the interface.
With the default implementation of interface members, C# 8 widens the interface type syntax to include the following features:
- Interfaces can now define bodies for methods, properties, indexers, and events.
- Interfaces may declare static members, including static constructors and nested types.
- They may explicitly specify visibility modifiers, such as private, protected, internal, and public (which continues to be the default).
- They may also specify other modifiers, such as virtual, abstract, sealed, extern, and partial.
The syntax for this new feature is straightforward...