In C#, why can an IEnumerable be assigned to a variable of type IEnumerable?
Correct answer A. Because IEnumerable<out T> is covariant in T
Explanation
IEnumerable declares its type parameter as out T, making it covariant: a sequence of a more derived type can be used as a sequence of a less derived one, since items are only read. List is not covariant, so List cannot be assigned to List
Answer checked How we write and check questions
Discussion