02 2014 档案

摘要:Action[] tmp = new Action[3];for (int i = 0; i Console.WriteLine(i);}Array.ForEach(tmp, m => m());Console.Read();猜猜打印结果会是啥,012 ?结果吓一跳自己仔细想想差不多明白了,闭包是嵌套的,外面一级变量i在作用域里,所以他会返回i最后的值。修改了下Action[] tmp = new Action[3];for (int i = 0; i Console.WriteLine(j);}Array.ForEach(tmp, m => m());Console.Read() 阅读全文
posted @ 2014-02-06 16:50 HONT 阅读(1212) 评论(0) 推荐(0) 编辑