Action的小笔记

有点像委托 但是 是委托吗 我不懂

using System;
using System.Collections.Generic;

namespace ConsoleTest
{
class Program
{
static void Main(string[] args)
{
List
<Action> ls = new List<Action>();
for (int i = 0; i < 10; i++)
{
ls.Add(()
=> Console.WriteLine(i));
}

foreach (Action action in ls)
{
action();
}
System.Console.Read();
}
}

}

 这样 输出的结果是 10个10 ,为什么是10个10 而不是 0-9 请看 http://www.cnblogs.com/yjmyzz/archive/2009/03/13/1410924.html

但 这个例子 让人 明白了 action的作用 就是 委托,就是把方法扔进去 

posted @ 2011-04-10 11:30  张土土  阅读(129)  评论(0编辑  收藏  举报