Imagine a situation where two marker interfaces A and B guard single Base interface:
interface Base
{
void Hello();
}
interface A: Base
{
}
interface B: Base
{
}
Is there a way to define class C that implements both A and B while providing marker interface specific Hello implementations? Note that Base, A and B interfaces are declared in an external library so I could not modify it.
If I do this
class C: A, B
{
void A.Hello() =>
Console.Out.WriteLine("A");
void B.Hello() =>
Console.Out.WriteLine("B");
}
...it results in CS0539 compiler error:
member in explicit interface declaration is not a member of interface.