public static void Demo()
        {
            // Match delegate signature
            GetAnimalDelegate <Animal> getADelegate2 = new GetAnimalDelegate <Animal>(GetAnimal);
            // Covariance
            GetAnimalDelegate <Animal> getADelegate1 = new GetAnimalDelegate <Cat>(GetCat);

            // Match delegate signature
            SetCatDelegate <Cat> setCatDelegate2 = new SetCatDelegate <Cat>(SetCat);
            // Contravariance
            SetCatDelegate <Cat> setCatDelegate1 = new SetCatDelegate <Animal>(SetAnimal);
        }
 public DelgateVarianceTest()
 {
     updateNameMethod = UpdateName;
     getAnimalMethod  = GetDog;
 }
Пример #3
0
 static void DelegateCovariance( )
 {
     GetAnimalDelegate delegate1 = GetAnimal;
     GetAnimalDelegate delegate2 = GetBird;
 }