예제 #1
0
        static void Main()
        {
            Animal[] animals = new Animal[4];
            animals[0] = new Cat("Tom", 10, "Mujko");
            animals[1] = new Dog("Sparky", 5, "Mujko");
            animals[2] = new Frog("Gufi", 3, "Mujko");
            animals[3] = new Kitten("Liza", 6, "Jensko");

            double averageAge = animals.Average(animal => animal.Age);

            Console.WriteLine(averageAge);
        }
예제 #2
0
        static void Main()
        {
            Animal[] animals = new Animal[4];
            animals[0] = new Cat("Tom", 10, "Mujko");
            animals[1] = new Dog("Sparky", 5, "Mujko");
            animals[2] = new Frog("Gufi", 3, "Mujko");
            animals[3] = new Kitten("Liza", 6, "Jensko");

            double averageAge = animals.Average(animal => animal.Age);

            Console.WriteLine(averageAge);
        }