The average age of all females - revisited. | Lecture 16 - slide 10 : 11 Program 1 |
using System; using System.Collections.Generic; using System.Linq; public class Example1{ public static void Main(){ // The average age of all females: double result = Person.SomePersons .Where(p => p.Sex == Sex.Female) .Select(p => p.Age) .Average(); Console.WriteLine("Result = {0}", result); // Result = 37,3333333333333 } } |