The out keyword marks a type
parameter as covariant, and the in keyword marks it as
contravariant. The two most important rules to remember:
- You can mark a generic type parameter as covariant if
it is used only as a method return type and is not used as a type of
formal method parameters.
- And vice versa, you can mark a type as contravariant if
it is used only as a type of formal method parameters and not used as a
method return type.
