Covariance for classes with list members in C#
问题 Consider a class hierarchy that looks as below. In essence, there is an abstract ComplexBase with some fields that are common to all classes. Then there is a ComplexClass derived from ComplexBase that, among other things, holds a collection of ComplexElement s also derived from ComplexBase . public abstract class ComplexBase { internal abstract string Identifier { get; } } public abstract class ComplexClass<T> : ComplexBase where T : ComplexElement { internal SortedList<string, T> Elements {