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