Covariance and Contravariance on the same type argument

后端 未结 7 746
时光取名叫无心
时光取名叫无心 2021-01-02 06:45

The C# spec states that an argument type cannot be both covariant and contravariant at the same time.

This is apparent when creating a covariant or contravariant int

7条回答
  •  猫巷女王i
    2021-01-02 06:52

    Without out and in keywords argument is Covariance and Contravariance isn't it?

    in means that argument can only be used as function argument type

    out means that argument can be used only as return value type

    without in and out means that it can be used as argument type and as return value type

提交回复
热议问题