I am trying to implement a very simple interface and use it to access a property of a type that is accessed directly through the interface:
interface ITest { IOther Other { get; } } interface IOther { } class Other : IOther { } class Test : ITest { public Other Other { get; set; } }
However, I get the following build error:
Error 13 'Test' does not implement interface member 'ITest.Other'. 'Charger.Shared.Test.Other' cannot implement 'ITest.Other' because it does not have the matching return type of 'IOther'.
Now I understand what the error says, but I cannot understand why. Other implements IOther, so why the problem?
The wrong solution would be to explicitly implement the interface:
class Test : ITest { public Other Other { get; set; } IOther ITest.Other { get { return this.Other; } } }
Why is this template needed?
Thanks.
EDIT: Suppose in the actual custom code where I am having this problem, declaring Test as this is not an option:
class Test : ITest { public IOther Other { get; set; } }
source share