Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Return the most specific type from the method, and take the most general type in the arguments.
https://en.wikipedia.org/wiki/Covariance_and_contr...
For example, in C#, if Cat is a subtype of Animal, then:
IEnumerable<Cat>
is a subtype ofIEnumerable<Animal>
. The subtyping is preserved becauseIEnumerable<T>
is covariant on T.Action<Animal>
is a subtype ofAction<Cat>
. The subtyping is reversed becauseAction<T>
is contravariant on T.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question