Writing Lambda Expressions in the .NET Framework
- Introduction
- Whats in a Lambda?
- Understanding Closures
- Currying
- Summary
Introduction
At the last Most Valuable Professionals (MVP) Summit, Sean O’Driscoll, then lead for Microsoft’s MVP program, included a nice little bit in his presentation about customer satisfaction, loyalty, and affinity. Here’s how I would define those terms:
- Satisfaction. What you have meets the customer’s needs.
- Loyalty. Exhibits behaviors such as recommending your products or services.
- Affinity. Likely to defend you. That is, when you goof, those who have an affinity for your products or services will defend you.
I bring this up because I hover somewhere between affinity and loyalty for Microsoft’s products. I’ll defend Microsoft if I think their stuff is good or "best in breed." MDNA was marketing; I couldn’t really defend that. The .NET Framework is great and it’s easy to defend, if defense is even needed. (By the way, since I’m not a Microsoft employee, it’s unlikely that I would ever be an apologist for them. They still have to do a good job, and for me that means that Microsoft’s development tools have to be cool and fun.)
I thought maybe this article would have to defend Lambda expressions. At first, Lambda expressions seemed too clever. Based on Lambda calculus, Lambda expressions are very small, compact, anonymous methods that use a special token, =>. In reality, Lambda expressions are based solidly on extension methods and a critical part of cool capabilities like Language-Integrated Query (LINQ).
In this article, you’ll learn how Lambda expressions work, including closures and currying. You’ll also learn why Lambda expressions are needed along the way. Enjoy!