using System;
delegate int MyDelegate();
delegate float Mydelegate1();
class Test
{
static MyDelegate F()
{
int x = 0;
MyDelegate result = delegate
{
return ++x;
};
return result;
}
static Mydelegate1 F2()
{
int x = 0;
Mydelegate1 result = delegate
{
x += 2;
return x ;
};
return result;
}
static void Main()
{
MyDelegate d = F();
Console.WriteLine(d());
Console.WriteLine(d());
Console.WriteLine(d());
Mydelegate1 d1 = F2();
Console.WriteLine(d1());
Console.WriteLine(d1());
Console.WriteLine(d1());
}
}
沒有留言:
張貼留言