This is LINQ (using query syntax):
var _Results = from item in _List where item.Value == 1 select item;
This is also LINQ (using method syntax):
var _Results = _List.Where(x => x.Value == 1);
It is interesting to note that both of these flavors ultimately produce the same code. The compiler offers you a service, allowing you to express your wishes as you prefer.
And this one is lambda:
x => x.Value == 1
When you decide to use the method syntax, LINQ almost always occurs around lambda expressions. But LINQ and lambdas are two completely different things that can be used on their own.
Update:. As you can see from the line, LINQ with query syntax is also implemented using lambda expressions (as mentioned earlier, the compiler allows you to write in the query syntax, but effectively converts it to the method syntax behind your back). It is simply an imposition that both tastes are completely equivalent and will behave the same (for example, lambda expressions can cause closures ).
Jon Sep 12 '11 at 17:07 2011-09-12 17:07
source share