For a while now I’ve been wondering why C#‘s support for covariance does not cover value types, both in normal array covariance and covariance in the generic parameter introduced in C# 4:
Until I stumbled upon this old post by Eric Lippert on the topic of array covariance, which essentially points to a disagreement in the C# and CLI specification on the rule of array covariance:
“if X is assignment compatible with Y then X is assignment compatible with Y”
“if X is a reference type implicitly convertible to reference type Y then X is implicitly convertible to Y”
Whilst this doesn’t directly point to the generics case with IEnumerable<out T>, one would expect they are one and the same, otherwise you end up with different rules for int and IEnumerable<int> where (new int is IEnumerable<int>) == true.. now that would be weird!