Apart from convariance and contravariance available in assignments, parameter types and return types, it is available for genericand delegate types also from C# 4.0 onwards. Covariant types convert from a wider type to narrower type. (e.g., int to short.).Contravariant types convert from a narrower type to a wider type(For example, from string to object.).
Example:
Output: ContravariantOutput: Covariant
No comments:
Post a Comment