代码简单,直接上代码了
复制代码 代码如下:
private static void Before()
{
Action[] actions = new Action[10];
for (var i = 0; i < actions.Length; i++)
{
actions[i] = () =>
{
Console.WriteLine(i);
};
}
foreach (var item in actions)
{
item();
}
}



