interface IBase {
char GetValue();
}
interface IDerivedAlpha : IBase {
char IBase.GetValue() => 'A';
}
interface IDerivedBravo : IBase {
char IBase.GetValue() => 'B';
}
class ExampleClass : IDerivedAlpha, IDerivedBravo {
public char GetValue() => 'C'; // We must provide an implementation here or the compiler will emit an error
}
class Program {
static void Main() {
var e = new ExampleClass();
Console.WriteLine(e.GetValue()); // Prints 'C'
Console.WriteLine(((IDerivedAlpha) e).GetValue()); // Prints 'C'
Console.WriteLine(((IDerivedBravo) e).GetValue()); // Prints 'C'
}
}
Code snippet taken from "Complete C# Quick Reference - C# 8".