using System;
delegate void MyDelegate();
class Test
{
static MyDelegate[] F()
{
MyDelegate[] result = new MyDelegate[3];
int x=0;
for (int i = 0; i < 3; i++)
{
int y = 0;
result[i] = delegate
{
Console.WriteLine("{0} {1}",++x,++y);
};
}
return result;
}
static void Main()
{
foreach (MyDelegate d in F()) d();
}
}
沒有留言:
張貼留言