From the course: Advanced C#: Functional Programming Patterns

Unlock this course with a free trial

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

Map with LINQ select

Map with LINQ select

- [Instructor] We'll start by looking at the functional map. And I talked about this in the slides. This is the equivalent in LINQ of calling the select extension method. The idea is it transforms each item in the list. So let's start by creating a list of integers using a numeral that range from one to 50. And then I'm going to show you two different ways of running this LINQ query. One is I can use the extension method. That's what I'm doing here on line 21, and on line 24 and 25, I'm using what's called a query expression, which is a more SQL-like syntax, but they both are equivalent. You can essentially think of this expression as being converted by the compiler into the code that's here in this select method. What am I doing here? I am working with the list of T. This is a list of integers and that implements I enumerable, so that means I can use it here, like this, numbers.Select, and then here's where I…

Contents