What different between IData< out T> and IData< T> ?
Asked
Active
Viewed 399 times
1 Answers
5
consider,
class Fruit {}
class Banana : Fruit {}
interface ICovariantData<out T> {}
interface IData<T> {}
and the functions,
void Peel(IData<Fruit> fruitData) { }
void Peel(ICovariantData<Fruit> fruitData) { }
The function that accepts ICovariantData<Fruit> will be able to accept ICovariantData<Fruit> or ICovariantData<Bananna> because it is a covariant interface and Banana is a type of Fruit,
the function that accepts IData<Fruit> will only be able to accept IData<Fruit>.
Jodrell
- 32,967
- 4
- 79
- 120
-
+1 for the simplest way of explanation – BRAHIM Kamel Dec 18 '13 at 14:35