Co- and Contravariance

Most of the C# 4.0 language features deal with dynamic typing and simplifying interoperability scenarios, but one other feature did make it in to the language update. Generic co- and contravariance is a powerful feature with a scary name. Luckily, you won’t have to deal with it directly that often. Instead, this new feature makes working with certain generic interfaces and delegates easier. Let’s have a look.

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.