Un FruitDelegate <Frutta> è un delegato che accetta alcun frutto. Ad esempio, vale quanto segue:
FruitDelegate<Fruit> f = new FruitDelegate<Fruit>(EatFruit);
f(new Apple());
f(new Banana());
è possibile rendere il parametro di tipo T di FruitDelegate <T>contravariant:
public delegate void FruitDelegate<in T>(T o) where T : Fruit;
che consente di assegnare un FruitDelegate <frutta> istanza a FruitDelegate <Apple> variabile:
FruitDelegate<Apple> f = new FruitDelegate<Fruit>(EatFruit);
f(new Apple());
Questo è valido, perché il delegato riferisce ad un metodo che (tra altri frutti) accetta mele.
Tuttavia, non è possibile assegnare un FruitDelegate < di Apple > istanza a un FruitDelegate <Frutta> variabile:
FruitDelegate<Fruit> f = new FruitDelegate<Apple>(EatApple); // invalid
f(new Apple());
f(new Banana());
Questo non è valida, perché il delegato dovrebbe accettare alcun frutto, ma rimanda alle un metodo che non accetta frutti diversi dalle mele.
Conclusione: non è possibile aggiungere un FruitDelegate < di Apple > esempio a una lista di < FruitDelegate <Frutta> >, perché un FruitDelegate < di Apple > non è un FruitDelegate <Frutta>.