У меня есть интерфейс IChild
и IParent
.
IParent
имеет a List<IChild>
.
Почему класс, реализующий IParent
, не может иметь список классов, реализующих IChild
Каков общий способ достижения этого?
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; }
}
Выдает следующую ошибку:
`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>`