02 LINQ Background
03 LINQ applied
Filter data with Where
We've built up our understanding of LINQ using
Where(predicate) in the last section.
You can apply
Where to restrict the result set to contain only elements that satisfy a specified condition.
Return all people, who are at least 30 years old.
public class FilterPeopleWithLinq
public IEnumerable<Person> KeepAdults(IEnumerable<Person> people)
return people.Where(p => p.Age >= 30);
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.