Eric Lippert is on the C# Compiler team and has written a series of posts on this topic that are an absolute must-read!
- Part One
- Part Two: Array Covariance (and Why is covariance of value-typed arrays inconsistent?)
- Part Three: Method Group Conversion Variance
- Part Four: Real Delegate Variance
- Part Five: Higher Order Functions Hurt My Brain
- Part Six: Interface Variance
- Part Seven: Why Do We Need A Syntax
- Part Eight: Syntax Options
- Part Nine: Breaking Changes
- Part Ten: Dealing With Ambiguity
- Part Eleven: To infinity, but not beyond
The information here is quite “flat”, but still worth a read.
- Microsoft Research: Variance and Generalized Constraints
Pages 1-9, OK. After that I can’t follow anymore.
- Exact rules for variance validity
Very poorly written, if you ask me.
The names covariance and contravariance in C# derive from co- and contravariant functors described in category theory.
- A Gentle Introduction to Category Theory
- What’s the difference between covariance and assignment compatibility?
How category theory applies to C# Co- and Contravariance
Hope that helps!