A comma-separated list of all male first names, youngest first - revisited. | Lecture 16 - slide 10 : 11 Program 3 |
using System; using System.Collections.Generic; using System.Linq; public class Example1{ public static void Main(){ // A comma-sep. list of all male first names, youngest first. string result = Person.SomePersons .Where(p => p.Sex == Sex.Male) .OrderBy(p => p.Age) .Select(p => p.FName) .Aggregate("", (res, nm) => res + " " + nm); Console.WriteLine("Result = {0}", result); // Result = Per Stig Martin } } |