Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

variance

Whether a generic type can stand in for a related one, like IEnumerable for IEnumerable.

Covariance (out) and contravariance (in) on interface and delegate type parameters allow implicit reference conversions between constructed types.

Examples

  • IEnumerable<object> items = words; works when words is an IEnumerable<string>; the same with List<object> and List<string> is error CS0029.

Read the full section →