Given the following class and interface:
public class Test<T> { } public interface ITesting<T> { Test<T> LoadTest(); } I can add a class with the following:
public class TestManager : ITesting<object> { #region ITesting public Test<object> LoadTest() { return new Test<object>(); } #endregion } Which works fine and throws no errors. If I try to replace that class with the following:
public class TestDerived : Test<object> { } public class TestDerivedManager : ITesting<object> { #region ITesting public TestDerived LoadTest() { return new TestDerived(); } #endregion } I now get the following error:
Error 'TestDerivedManager' does not implement interface member 'ITesting.LoadTest()'. 'TestDerivedManager.LoadTest()' cannot implement 'ITesting.LoadTest()' because it does not have the matching return type of 'Test'.
But to me it seems like this should work as TestDerived is Test<object>. I'm obviously not understanding something correctly here. Could someone possible point me to details on why this is incorrect? And possibly what I might do to correct it?
interface I { Animal M(); } class C : I { public Giraffe M() { return new Giraffe(); } }you'd get the same error.