class Program
{
delegate string del(int i);//自定义委托
static public Action A;
static public Action<int> B;
static public Action<int, string> C;
static public Func<string,string,string> fB;//第最后一个参数为返回
static public calculate GetCal() => new calculate();//lambda方法定义
static void Main()
{
del d = n => {
string s = n + " World";
return s;
};
Console.WriteLine(d(10));//执行
GetCal();
fB = (m,n) => { return m+n+"abc"; }; Console.WriteLine(fB("123","789"));
A = () =>
{
Console.WriteLine("I'm A ");
};
B = (i) =>
{
Console.WriteLine("I'm B " + i);
};
C = (int i, string s) =>
{
Console.WriteLine("I'm C " + i + " " + s);
};
A();
B(1);
C(1, "a");
testAction(() => { Console.WriteLine("run action"); });//执行action
Console.ReadKey();
}
static void testAction(Action ac)
{
ac();
}
}