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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Karthik AgarwalRank #2,270 · 620 reputationPosted Nov 24, 2011, 11:26 PM EST
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
Satyapriya NayakRank #47 · 31.5K reputationPosted Nov 25, 2011, 12:01 AM EST
Please refer Our recommended articles.
Thanks
Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 2, 2012, 9:35 PM EST
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