static void Main(string[] args)
{
GetGun()();//lambda表达式调用
GetGun1()();//匿名函数调用
GetGun2()();//函数调用
//Console.WriteLine(NiMingTest(2)(3));
}
static Action GetGun()//使用lambda表达式
{
Action action = null;
for (int i = 1; i <=10; i++)
{
int index = i;
action += () =>
{
Console.WriteLine(index);
};
}
return action;
}
static Action GetGun1()//使用匿名函数
{
Action action = null;
for (int i = 1; i <= 10; i++)
{
int index = i;
action += delegate()
{
Console.WriteLine(index);
};
}
return action;
}
static Action GetGun2()//使用函数调用
{
Action action = null;
for (int i = 1; i <= 10; i++)
{
int index = i;
action += ()=>
{
Fzp(index);
};
}
return action;
}
static int Fzp(int i)
{
Console.WriteLine(i);
return i;
}