=>用于lambda表达式
using System; Action<string> greet = name => { string greeting = $”Hello {name}!”; Console.WriteLine(greeting); }; // (input) => () 后面用小括号可以吗 Action obj1; obj1 = () => { Debug.Log("FGNB"); }; Action<int> obj2; obj2 = (int x) => { Debug.Log(x); }; obj2 = (x) => { Debug.Log(x+233); };//也可以省略参数类型,最好不要 Func<int,int> obj3 = (int x) => { return x; }; Func<int, bool> equalsFive = x => x == 5; // 如果就是一个变量,不需要后面加括号,也不需要return bool result = equalsFive(4); Console.WriteLine(result); // Action没有返回值 // Func有返回值