Why can I not do the following?
public class TestClass : TestInterface
{
public ClassX Property { get; private set; }
}
public interface TestInterface
{
InterfaceX Property { get; }
}
public interface InterfaceX
{
}
public class ClassX : InterfaceX
{
}
The TestInterface Property is readonly, thus can only return InterfaceX as per the contract.
However, I get this compiler error:
'TestClass' does not implement interface member 'TestInterface.InterfaceX'. 'TestClass.InterfaceX' cannot implement 'TestInterface.InterfaceX' because it does not have the matching return type of 'InterfaceX'.
It does not have the matching type but it has a subclass of that type.