linq/ex1-qs.cs - Same program with use of query syntax. | Lecture 16 - slide 10 : 11 Program 2 |
using System; using System.Collections.Generic; using System.Linq; public class Example1{ public static void Main(){ // The average age of all females: IEnumerable<int> ages = from p in Person.SomePersons where p.Sex == Sex.Female select p.Age; double result = ages.Average(); Console.WriteLine("Result = {0}", result); // Result = 37,3333333333333 } }