H
hufaunder
I have a class "TestSuper" that implements the interface "TestBase".
The interface has a property of type "ReturnType". The class
"TestSuper" does not return "ReturnType" but a derivation
"ReturnSuper". This gives the following compile error due to a bad
return type:
TestSuper does not implement interface member TestBase.Func.
TestSuper.Func is either static, not public, or has the wrong return
type.
Why is it not possible that the derivated type "ReturnSuper" can be
defined as the return type in the class "TestSuper"?
class ReturnBase{}
class ReturnSuper : ReturnBase { }
interface TestBase
{
ReturnBase Func { get; }
}
class TestSuper : TestBase
{
public ReturnSuper Func { get { return new ReturnSuper(); } }
}
The interface has a property of type "ReturnType". The class
"TestSuper" does not return "ReturnType" but a derivation
"ReturnSuper". This gives the following compile error due to a bad
return type:
TestSuper does not implement interface member TestBase.Func.
TestSuper.Func is either static, not public, or has the wrong return
type.
Why is it not possible that the derivated type "ReturnSuper" can be
defined as the return type in the class "TestSuper"?
class ReturnBase{}
class ReturnSuper : ReturnBase { }
interface TestBase
{
ReturnBase Func { get; }
}
class TestSuper : TestBase
{
public ReturnSuper Func { get { return new ReturnSuper(); } }
}