111,119
社区成员
发帖
与我相关
我的任务
分享
public class LambdaTest
{
static void Main()
{
var counter = 0;
WriteStream(() => counter++);
Console.WriteLine("Final value of counter: {0}", counter);
}
static void WriteStream(Func<int> counter)
{
for (var i = 0; i < 10; ++i)
{
Console.WriteLine("{0}, ", counter());
}
}
}
}