2

I have the following classes defined.

 public class Animal { }
 public class Mammal : Animal { }

Why is the following lambda statement illegal in c#

Action<Mammal> m2 = (Animal a) => { }; 

But the following works fine.

Action<Mamal> m2 = MethodThatTakesAnimal;

MethodThatTakesAnimal has the following signature

public static void MethodThatTakesAnimal(Animal animal) { }
Shaz
  • 43
  • 5

0 Answers0