Covariance and Contravariance in generics example

A quick working example of Covariance and Contravariance in generics for a reference of when in and out C# keywords can be used.

There are a lot of useful blog posts explaining Covariance and Contravariance, e.g. mathemetical model behind it, and all the technical details.

Below is a simple code snippet illustrating what effect in and out C# keywords have when used in generics. Lines that cause compilation error are commented out.