From the course: .NET Essentials: Working with LINQ

Unlock this course with a free trial

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

Learn how to use the Enumerable static methods

Learn how to use the Enumerable static methods - .NET Tutorial

From the course: .NET Essentials: Working with LINQ

Learn how to use the Enumerable static methods

- [Instructor] At the top of the code, I'm declaring a instance of a list of strings. And I'm filling it with some color names. Now we know that list of strings implements Enumerable of t. And that means it's queryable using the extension methods that are part of the enumerable type. So before I show you the query, let's dump out the original values. So here's the original list of values. They're not in alphabetical order. And what I want to do is query this to find only the colors to start with the letter B. So querying like that, that's a filter and filters are implemented in link with the where extension method. So here's the syntax, I call Enumerable.where. The first argument is a type that implements or an instance of a type that implements Enumerable t, so that's my colors. The second argument is a predicate function that is used to determine whether or not the candidate string belongs in the output. So…

Contents