Example #1
0
        public static void AverageAge(Animal[] animals)
        {
            var animalsByType = animals.GroupBy(x => x.GetType());

            foreach (var animal in animalsByType)
            {
                Console.WriteLine(animal.Key + " average age: " + animal.Average(x => x.Age)); 
            }
        }