Efficiently return IList<Interface> from List<T> (avoid casting from List<T> to List<I>)
问题 I have the following code: public interface ISomeObject { IList<ISomeObject> Objects { get; } } public class SomeObject : ISomeObject { public SomeObject() { Objects = new List<SomeObject>(); } public List<SomeObject> Objects { get; set; } IList<ISomeObject> ISomeObject.Objects { get { // What to do here? // return Objects; // This doesn't work return Objects.Cast<ISomeObject>().ToList(); // Works, but creates a copy each time. } } SomeObject has a public property Objects that returns a List