C# 8.0 Interface default implementation

In the upcoming C# 8.0, interface can have default implementation of members. The class implementing interface can provide its own implementation otherwise the default implementation from the interface is used.

This feature allows to safely add members to an interface already released while existing client can continue to work without any change.

Above code gives error during compilation:

Now let’s add default implementation to the interface so that existing client can continue to work without change.

Final words:

A class implementation of an interface member should always win over a default implementation in an interface, even if it is inherited from a base class.

Default implementation in an interface are fall back only when the class does not have any implementation of the member at all.