Action a1 = () => { Console.WriteLine("hello"); };
Action a2 = () => Console.WriteLine("hello"); //方法体只有一行时,可省略花括号
Action<int> b1 = (param) => Console.WriteLine("hello");
Action<int> b2 = param => Console.WriteLine("hello");//只有一个参数时,可省略小括号
Func<int> c1 = () => { return 3 + 2; };
Func<int> c2 = () => 3 + 2;//方法体只有一行时,可省略花括号和 return
Func<int, string> c3 = param => param + 8 + "";
C# lambda表达式写法
最新推荐文章于 2023-06-19 15:40:41 发布