c#闭包使用方法示例_C#教程

分享到:

代码简单,直接上代码了


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();
            }
        }

昵    称:
验证码:

相关文档: