Variance

De Banane Atomic
Aller à la navigationAller à la recherche

Links

Description

Covariance enable implicit reference conversion for array types, delegate types, and generic type arguments.
Covariance preserves assignment compatibility and contravariance reverses it.

Assignment compatibility

Cs.svg
string s = "test";  

// An object of a more derived type is assigned to an object of a less derived type.
object o = s;