class Program
{
static void fnnn()
{
string[] k = new string[] { "x", "y", "z" };
List<Action> list = new List<Action>();
foreach (string i in k)
{
list.Add(delegate() { Console.WriteLine(i); });
}
foreach (Action action in list)
{
action();
}
}
static void Main(string[] args)
{
fnnn();
Console.Read();
}
}
在.net 2.0上输出的是 Z,Z,Z
在net 4.0上输出的是 X,Y,Z