>>I thought I'd used this sort of construct before. But the compiler insists that the type of Parent in Test must be BaseClass.
>
public interface ITest
>> {
>> BaseClass Parent { get; }
>> }
>>
>> public class BaseClass {}
>>
>> public class DerivedClass : BaseClass{}
>>
>> public class Test : ITest
>> {
>> public DerivedClass Parent
>> {
>> get {return new DerivedClass(); }
>> }
>> }
Am I cracking up?
>
>Viv,
>
>I agree with Bonnie
>
>Your interface says the return type should be BaseClass and you're returning another type. iow the signature of the interface does not match
>
>See last line of error message ( I have taken my namespace out to make it clearer)
>
>
>Error 1 'Test' does not implement interface member 'ITest.Parent'.
> 'Test.Parent' cannot implement 'ITest.Parent' because it does not have the matching return type of 'BaseClass'.
>
Hi,
See my reply to Bonnie.
I understand the nature of the complaint but not why the compiler needs to make it :-}
Best,
Viv