Overview
A filtering operation restricts the result set to contain only those elements that satisfy a specified condition. The condition is called a predicate.
methods
Method | Description | Query expression |
---|---|---|
OfType | Selects values depending on their ability to be cast to the specified type | N/A |
Where | Selects values based on a predicate function | where |
example
string[] words = [ "the", "quick", "brown", "fox", "jumps" ];
In method syntax:
IEnumerable<string> query =
words.Where(word => word.Length == 3);
In query syntax:
IEnumerable<string> query = from word in words
where word.Length == 3
select word;