From the course: Advanced C#: Functional Programming Patterns

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Filter with LINQ where

Filter with LINQ where

- [Instructor] Our next functional concept to study is filter. In LINQ, that's implemented as the where method. And the idea what the filter is it returns a subset of the list based on a predicate function. A predicate function is one that returns booleans. So the calculation determines whether the item belongs in the output list or not. I start with 200 integers on line 14. Then, on line 16, I am using two extension methods. Here's the where method and the predicate is X is less than 20. And then I'm pipelining that with the select and I'm using a pass through here. On line 18 through 20, I'm doing the query expression. The code is nearly identical except, in the where clause, I have N less than 20 or it's greater than 180. Now, let's talk about something here. In the extension methods, I have to, I don't need select. That's optional but when you're doing the query expression, you need to end with select or select many or…

Contents