Skip to content

IReadOnlyCollection doesn't have a Contains method #66890

Answered by Joe4evr
bollhals asked this question in General
Discussion options

You must be logged in to vote

Probably because it's more beneficial for IReadOnlyCollection to be covariant (<out T>) which means T can only appear in the output position of a member signature (aka the return type) in order to abide by that contract. With Contains, the T appears in an input position and therefore means that the entire interface must be invariant, losing the benefits.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@daiplusplus
Comment options

Answer selected by bollhals
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants