C# 模仿使用Swift中的函数类型Func
delegate string deleMethod(int a, string b); //声明一个函数 string method(int c, string d){ return c+d; } string method2(int c, string d){ return c*(int)d; } //1.通过函数名赋值 deleMethod A = method; A(1, "2");// "12" A = method2; A(1, "2");// 2
//2.作为参数 string test(deleMethod m){ return m(1,"aaa"); } test(new deleMethod(method)); test(method);