Bit surprised why this does not work
Is this a limitation of the compiler or does it make good sense not to support it?
public class Class1<T> : IInterface
where T : Test2
{
public T Test { get; private set; }
}
public class Test2
{
}
internal interface IInterface
{
Test2 Test { get; }
}
The error I get is
'ClassLibrary1.Class1<T>' does not implement interface member 'ClassLibrary1.IInterface.Test'.
'ClassLibrary1.Class1<T>.Test' cannot implement 'ClassLibrary1.IInterface.Test' because it does not have the matching return type of 'ClassLibrary1.Test2'.
Class1need to be generic? If return type ofTestisTest2, then make it return this type and you're done. You will be able to return any types derived fromTest2anyway.