The overall variance in .NET 4 does not matter here. The implementation of the interface must match the signature of the interface exactly in terms of types.
For example, take ICloneable , which looks like this:
public interface ICloneable { object Clone(); }
It would be nice to implement it like this:
public class Banana : ICloneable { public Banana Clone()
... but .NET does not allow this. Sometimes you can use an explicit implementation of an interface implementation, for example:
public class Banana : ICloneable { public Banana Clone() { ... } object ICloneable.Clone() { return Clone();
However, in your case, you can never do this. Consider the following code that would be valid if ConcreteContainer considered implemented by IContainer :
IContainer foo = new ConcreteContainer(); foo.Children = new List<IChild>();
Now your property setter is actually declared to work with EntityCollection<ConcreteChild> , so it obviously cannot work with any IEnumerable<IChild> - in violation of the interface.
Jon skeet
source share