Aller au contenu

Variance

De Banane Atomic

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

string s = "test";  

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