lambda Expressions Simplify the use of anonymous delegates, allowing you to make your code more concise and elegant. It is said to be one of the most important features that Microsoft has added since c#1.0.
First look at its development
Depending on the development process above, you can feel that lambda expressions are more streamlined.
Detailed Description:
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespacelambda{classProgram {Static voidMain (string[] args) { intsum =0; Func<int,int> f1 = x = =2* x +1; Func<int,int,BOOL> F2 = (x, y) + x >y; Func<string,int,string> F3 = (x, y) = =x.substring (y); Func<int,int> f4 = (x) + sum + + +x; Action A1= () = {System.Console.WriteLine ("HelloWorld"); }; Action<int> a2 = (x) = ={System.Console.WriteLine (x);}; Action<BOOL> a3 = (x) = ={System.Console.WriteLine (x);}; Action<string> a4 = (x) = ={System.Console.WriteLine (x);}; for(inti =1; I <=Ten; i++) {f4 (i); } a2 (sum); A1 (); A2 (F1 (1)); A3 (F2 (3,5)); A4 (F3 ("Zhengpengfei",5)); System.Console.Read (); } }}
C # lambda expression