Resources on Covariance and Contravariance

Eric Lippert is on the C# Compiler team and has written a series of posts on this topic that are an absolute must-read!

  1. Part One
  2. Part Two: Array Covariance (and Why is covariance of value-typed arrays inconsistent?)
  3. Part Three: Method Group Conversion Variance
  4. Part Four: Real Delegate Variance
  5. Part Five: Higher Order Functions Hurt My Brain
  6. Part Six: Interface Variance
  7. Part Seven: Why Do We Need A Syntax
  8. Part Eight: Syntax Options
  9. Part Nine: Breaking Changes
  10. Part Ten: Dealing With Ambiguity
  11. Part Eleven: To infinity, but not beyond


The information here is quite “flat”, but still worth a read.


Category Theory

The names covariance and contravariance in C# derive from co- and contravariant functors described in category theory.

Hope that helps!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s