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 extension methods - .NET Tutorial
From the course: .NET Essentials: Working with LINQ
Learn how to use the Enumerable extension methods
- [Instructor] The extension method syntax simplifies the code, and it makes it easier, I think, to understand your intent. Here is the old version of the Where using the static method, Enumerable.Where, and then it takes two arguments, the colors instance and the lambda expression. The new syntax, you move the colors instance to the front of the expression, and you do .Where. You only have to pass a single argument into the Where method. That's the lambda expression. I think one of the main reasons it was added to .NET is to simplify this and also make it easier to string together function calls like this called pipelining. We'll look at that more later. Here is the old code for working with Last, Enumerable.Last colors. Here's the new syntax, colors.Last. I think that's a little bit more readable. And then as I said, it makes it easier to pipeline items. So here I can say colors.Where and then .Last. This would be…
Contents
-
-
-
-
-
-
What sources are queryable?2m 56s
-
The Enumerable class1m 14s
-
Learn how to use the Enumerable static methods3m 14s
-
Learn how to use the Enumerable extension methods1m 3s
-
Learn how to use the Query Expression syntax4m 17s
-
What sources revisited3m 52s
-
Deferred execution: When does the query run?3m 35s
-
Combine methods with execution pipelines2m 19s
-
Combine extension methods and query expressions3m 2s
-
-
-
-
-
-
-
-
-
-
-
-