In C# 3.0 + .Net 3.5 and up you can fix this by doing the following
List<ISomeInterface> interfaceList = new List<ISomeInterface>(list.Cast<ISomeInterface>());
The reason why this doesn't work is that the constructor for List<ISomeInterface>
in this case takes an IEnumerable<ISomeInterface>
. The type of the list variable though is only convertible to IEnumerable<objectA>
. Even though objectA
may be convertible to ISomeInterface
the type IEnumerable<objectA>
is not convertible to IEnumerable<ISomeInterface>
.
This changes though in C# 4.0 which adds Co and Contravariance support to the language and allows for such conversions.