-
Why does ICollection have a |
Beta Was this translation helpful? Give feedback.
Answered by
Joe4evr
Mar 19, 2022
Replies: 1 comment 1 reply
-
Probably because it's more beneficial for |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
bollhals
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Probably because it's more beneficial for
IReadOnlyCollection
to be covariant (<out T>
) which meansT
can only appear in the output position of a member signature (aka the return type) in order to abide by that contract. WithContains
, theT
appears in an input position and therefore means that the entire interface must be invariant, losing the benefits.