Covariance Articles

C# 4.0 – Covariance and Contravariance of Generics

Covariance allows casting of generic types to the base types, for example, IEnumerable<X> will be implicitly convertible an IEnumerable<Y> if X can implicitly be converted to Y. // List of strings IList<string> stringList = new List<string>(); // We can convert it to an Enumerable collection IEnumerable<object> Obj= strings; For this purpose IEnumerable is marked with [...]

Read more