Content deleted Content added
mNo edit summary |
Adds concise definition |
||
Line 1:
{{Type systems}}
Covariance is the quality of being different by being more specific ({{C sharp|Cat}} is covariant to {{C sharp|Animal}}). Contravariance is the quality of being different by being more general ({{C sharp|Animal}} is contravariant to {{C sharp|Cat}}).
Many [[programming language]] [[type system]]s support [[subtyping]]. For instance, if the type {{C sharp|Cat}} is a subtype of {{C sharp|Animal}}, then an expression of type {{C sharp|Cat}} [[Liskov_substitution_principle|should be substitutable]] wherever an expression of type {{C sharp|Animal}} is used.
|