Figure 9.2 demonstrates querying an array of integers using LINQ. Repetition statements that filter arrays focus on the process of getting the results—iterating through the elements and checking whether they satisfy the desired criteria. LINQ specifies the conditions that selected elements must satisfy. This is known as declarative programming—as opposed to imperative programming (which we’ve been doing so far) in which you specify the actual steps to perform a task. The query in lines 20–22 specifies that the results should consist of all the
ints in the
values array that are greater than
4. It does not specify how those results are obtained—the C# compiler generates all the necessary code, which ...