What C # function name allows you to implicitly treat List <ChildClass> as a list <ParentClass>
2 answers
You say general covariance - but that does not apply to List<T>
, which is invariant.
This only applies to IEnumerable<T>
:
IEnumerable<ChildClass> children = new List<ChildClass>(); IEnumerable<ParentClass> parents = children;
+14