Where()
noun
say it: “WAIR” /wɛr/
The LINQ method that keeps only the items that pass a test.
What does Where() do in C#?
Where() — A LINQ operation that keeps only items satisfying a condition.
class NameFilter
{
IEnumerable<string> ShortNames(IEnumerable<string> names)
{
return names.Where(name => name.Length < 5);
}
}
In a sentence
- “products.Where(p => p.UnitPrice < 10) keeps only the cheap products.”
Level: Freelancer · More C# terms at this level
Updated