Hi,
As I am new to LINQ please tell me what is Lambda expression?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Jan 3, 2012, 2:35 AM
A lambda expression is nothing but inline delegate function.
In lambda expression delegate and function both define in same line.
for more info please refer.
http://msdn.microsoft.com/en-us/library/bb397687.aspx
http://geekswithblogs.net/dotnetnomad/archive/2008/01/29/119037.aspx
Satyapriya NayakPosted Nov 25, 2011, 5:01 AM
Please refer Our recommended articles.
Thanks
Karthik AgarwalPosted Nov 25, 2011, 4:26 AM
All lambda expressions use the lambda operator =>, which is read as "goes to". The left side of the lambda operator specifies the input parameters (if any) and the right side holds the expression or statement block. The lambda expression x => x * x is read "x goes to x times x." This expression can be assigned to a delegate type as follows:
C#
Copy
delegate int del(int i);
static void Main(string[] args)
{
del myDelegate = x => x * x;
int j = myDelegate(5); //j = 25
}
To create an expression tree type:
C#
Copy
using System.Linq.Expressions;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Expression
myET = x => x * x;
}
}
}
The => operator has the same precedence as assignment (=) and is right-associative.
Lambdas are used in method-based LINQ queries as arguments to standard query operator methods such as Where.
Check this link for more info:
http://msdn.microsoft.com/en-us/library/bb397687%28v=VS.90%29.aspx