What are the kinds of covariance in C#? (Or, covariance: by example)

后端 未结 3 1591
后悔当初
后悔当初 2020-12-14 11:38

Covariance is (roughly) the ability to mirror inheritance of \"simple\" types in complex types that use them.
E.g. We can always treat an instance of Cat<

3条回答
  •  抹茶落季
    2020-12-14 12:15

    Java employs the concept of use-site variance for generic types: the needed variance is specified at each use site. This is why Java programmers are required to be familiar with the so-called PECS rule. Yes, it is unwieldy and has already received plenty of criticism.

提交回复
热议问题