Tag: LINQtoObjects
public class Person { public string Name { get; set; } public int Age { get; set; } public override string ToString() { return Name + " " + Age; } }
List<Person> persons = new List<Person>(); persons.Add(new Person() { Name = "Ken", Age = 30 }); persons.Add(new Person() { Name = "Tom", Age = 10 }); persons.Add(new Person() { Name = "Mike", Age = 20 }); persons.Add(new Person() { Name = "Joe", Age = 30 }); var results = from Person person in persons where person.Age > 15 select person; foreach (Person person in results) { Debug.WriteLine(person); } //Mike 20 //Joe 30 //