المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Usage of Lambda Expression



C# Programming
06-25-2009, 02:00 PM
I am an experienced developer in c# and working on LOB application from last 7 Years, I have some issues in understanding usage of Lambda expression in programming.

As far as i understand it is useful in case of

1) Working with LINQ (Grouping, Select,Where etc..)
2) We can pass Lambda expression to any function as argument, so it can be used in place of delegate or anonymous function or normal function.
3)We can create generic lambda function which takes any datatype variable as argument and can return any datatype
e.g.
MyFirstLambdaFunc((val1,val2) => val1+val2)
public R MyFirstLambdaFunc(Func lambdaexpression,T x,T y)
{
R Result = lambdaexpression(x, y);
return Result;
}
4)Coding can be compact

Now the question is that

1) Are there any other advantages ?
2) When we pass lambda expression as function we can pass only single line operation?
3) Can anybody have some case study or some practical example document ?

Thanks in Advance

Harish Bhattbhatt