If you have studied delegates, I am sure you have heard about covariance and contravariance. These were mainly introduced for non-generic delegates. However, from C# 4, these are also available for generic interfaces and delegates. The concepts of covariance and contravariance in generics is almost the same as it is in delegates. Let's look into this with examples.
Covariance and contravariance in generics
Covariance
This means that the generic interface that has a T type parameter can return T or any class that is derived from T. To achieve this, the parameter should be used with the out keyword. Let's see the generic form:
access-modifier interface-name<out T>{}