Kumar Gaurav

Kumar Gaurav

  • NA
  • 23
  • 17.9k

Lambda expression and anonymous method in c#

Oct 21 2015 1:55 AM
In interview they ask me one question i.e what is difference between lambda expression and anonymous method in c#.
I just told him like Anonymous mehods were introduced in C# 2 and Lambda expression in c# 3.
and suppose we have a list of employee  and we have to find employee details with id=105 than by using anonymous mehhod we
write like:
Employee employee= listEmployee.Find(delegate(Employee Emp)
{
return Emp.ID==105
});
And by using Lambda Expression:
Employee employee= listEmployee.Find(Emp=>Emp.ID==102);
means we can't use delegate as a parameter in Lambda Expression.
Lembda expression is mainly use to writing Linq query expression.
But i think Interviewer not satisfy that answer, than what i should have to exataly told?

Answers (1)