delegate void MyDelegate<in T>(T a); // in - Для аргумента. public static void CatUser(Animal animal) { Console.WriteLine(animal.GetType().Name); }
static void Main(string[] args) { Animal a1 = new Animal(); Animal a2 = new Dog(); Console.WriteLine("Number of legs: {0}", a2.NumberOfLegs); }
static void ActOnAnimal(Animal a) { Console.WriteLine(a.NumberOfLegs); }