C# Action 委託 + lambda 表示式
阿新 • • 發佈:2019-01-09
using System; using System.Collections; public class Test { static public Action A; static public Action<int> B; static public Action<int, string> C; static public Action<int, string, int> D; static public Action<int, string, int, string> E; static void Main() { A = () => { Console.WriteLine("I'm A "); }; B = (i) => { Console.WriteLine("I'm B " + i); }; C = (i, s) => { Console.WriteLine("I'm C " + i + " " + s) ; } ; D = (i, s, j) => { Console.WriteLine("I'm D " + i + " " + s + " " + j) ; } ; E = (i, s, j, t) => { Console.WriteLine("I'm E " + i + " " + s + " " + j + " " + t); }; A(); B(1); C(1, "a"); D(1, "a", 2); E(1, "a", 2, "b"); Console.ReadKey(); } }