In earlier versions of C# IEnumerable was defined like this:
public interface IEnumerable<T> : IEnumerable
Since C# 4 the definition is:
public interface IEnumerable<out T> : IEnumerable
- Is it just to make the annoying casts in LINQ expressions go away?
- Won't this introduce the same problems like with
string[] <: object[](broken array variance) in C#? - How was the addition of the covariance done from a compatibility point of view? Will earlier code still work on later versions of .NET or is recompilation necessary here? What about the other way around?
- Was previous code using this interface strictly invariant in all cases or is it possible that certain use cases will behave different now?