using System.Collections.Generic;
public Person(string name)
public static void Main()
var list = new List<Person>()
{new Person("Bob"), new Person("Ann"), new Person("Cat")};
foreach (var item in YieldNames(list))
static IEnumerable<string> YieldNames(List<Person> personList)
foreach (var person in personList)
yield return person.Name;