Nie można zaimplementować elementu interfejsu, ponieważ nie ma dopasowanego typu powrotu listy <Iinterfejs>

Mam interfejsyIChild iIParent. IParent ma członka, który jestList<IChild>.

Chcę mieć klasy, które implementująIParent gdzie każda klasa ma członka, który implementujeIChild:

public interface IChild
{ 
}  

public interface IParent
{  
    List<IChild> a { get; set; }
} 

public class ChildA : IChild
{ 
} 

public class ChildB : IChild
{ 
} 

public class ParentA : IParent
{ 
    public List<ChildA> a { get; set; }
}

public class ParentB : IParent
{ 
    public List<ChildB> a { get; set; }
}

Ale ten kod nie będzie się kompilował. Błąd jest:

`MyApp.Data.ParentA` does not implement interface member `MyApp.Data.IParent.a`.
`MyApp.Data.ParentA.a` cannot implement `MyApp.Data.IParent.a` because it does not have
the matching return type of `System.Collections.Generic.List<MyApp.Data.IChild>`.

questionAnswers(5)

yourAnswerToTheQuestion