Não é possível implementar o membro da interface porque ele não tem o tipo de retorno correspondente de List <IInterface>
Tenho interfacesIChild
eIParent
. IParent
tem um membro que é umList<IChild>
.
Eu gostaria de ter aulas que implementemIParent
onde cada classe tem um membro que implementaIChild
:
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; }
}
Mas esse código não será compilado. O erro é:
`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>`.