using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
public static void Main()
var stopwatch = new Stopwatch();
var people = GetPeople();
int underageCount = people.Where(person => person.Age < 18).Count();
int allCount = people.Count();
Console.WriteLine($"There are {underageCount} underage people out of {allCount}. This took {stopwatch.ElapsedMilliseconds}ms");
people = GetPeople().ToList();
underageCount = people.Where(person => person.Age < 18).Count();
allCount = people.Count();
Console.WriteLine($"There are {underageCount} underage people out of {allCount}. Took only {stopwatch.ElapsedMilliseconds}ms");
private static IEnumerable<Person> GetPeople()
yield return new Person { FullName = "Shepherd", Age = 24 };
yield return new Person { FullName = "Samsara", Age = 32 };
yield return new Person { FullName = "Talos", Age = 11 };
public string FullName { get; set; }
public int Age { get; set; }