Covariance and Contravariance in C# 1 - 11

bearophile bearophileHUGS at lycos.com
Sun Mar 21 04:34:38 PDT 2010


I have just started reading the articles of this series, but I think they can be useful to solve the problems like one in dmd bug 2563. They are titled "Covariance and Contravariance in C#" and they are eleven articles, you can see them here and in the successive page:

http://blogs.msdn.com/ericlippert/archive/2007/10/16/covariance-and-contravariance-in-c-part-one.aspx

After those eleven articles there is this too that seems related:
http://blogs.msdn.com/ericlippert/archive/2009/09/24/why-is-covariance-of-value-typed-arrays-inconsistent.aspx

And, all this is related to this feature added to C#4 (those articles are older than C#3):
http://en.wikipedia.org/wiki/C_sharp_4#Covariant_and_contravariant_generic_type_parameters

See the syntax:
interface IEnumerable<out T> {
  IEnumerator<T> GetEnumerator();
}

I have also asked something related in the d.learn group:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=19213

Bye,
bearophile



More information about the Digitalmars-d mailing list