Core Concept: Lambda (C#)

A lambda is an inline anonymous function.

Does that sound like JavaScript to you? It's because JavaScript has always had lambdas, and they're awesome!

First - check out the ES5 JavaScript syntax, because it's the least cryptic. In the following example, "map" runs a function on each project and constructs an array from the results. The function itself is very simple, accepting a project and returning the project name. Thus, we get an array of project names.

var projectNames = projects.map(function(p){
    return p.name;
});

Here is the newer ES6 syntax, which does the same thing:

var projectNames = projects.map((p)=> {
    return p.name;
});

OR shorter style that we can use because the function has ONE statement

var projectNames = projects.map((p)=>
    p.name
);

Now the same thing in C#:

var projectNames = projects.Select((p)=>
    p.name
);

Note - the lambda syntax, and general idea remains the same.

Alternatives

C# (and JavaScript) let you exchange your inline, anonymous, implicitly typed function for a normal function.

i.e. you can exchange a lambda for a normal function:

private static string getProjectName(Project p){
    return p.name;
}

...

var projectNames = projects.Select(getProjectName);

You can even exchange a lambda for a delegate, but I'm not going to because it makes me depressed to see that syntax.

You can have async lambdas:

var projectManagerNames = projects.Select(async (p)=>{
    var u = await UserDAL.GetUserAsync(p.projectManagerId);
    return u.FullName;
});

You can type the lambda arguments, if you want/need:

var projectNames = projects.Select((Project p)=>
   p.name;
}

I'm not even going to make a joke about Llamas. We were all thinking it.