What’s a Lambda Expression?
This article isn’t specifically about Lambda expressions, but so you won’t have to go somewhere else for this material here it is a nutshell.
Sometime in the 1980s for Windows programmers, but earlier in other languages, the event-driven model was added. An event is something that happens, such as a mouse click, but really can be anything. Events were supported by function pointers. The first version of events was a little clumsy because the function pointer could be null but it could be assigned to more than one thing.
.NET introduced the delegate—the objectification of an event. .NET events support multicasting, which simply means that one event can refer to multiple function pointers, and each is notified of an event. Because event handlers often were one-line functions, .NET introduced the anonymous delegate, which is simply a shorthand notation for a delegate (a function), sans the part of the function header.
A Lambda expression is a further-condensed version of an anonymous delegate that’s based on the Lambda calculus. Lambda expressions use the => goes to operator and further eliminate the need for the function header and the return keyword. The result is a compact and portable notation that yields expressions like this:
y => y + 5;
The preceding statement is the same as a function that accepts a cardinal value y and returns y + 5.