C# 闭包
作者:互联网
private static Action myDelegate()
{
int c = 0;
return delegate
{
c++;
Console.WriteLine(c);
};
}
private static void Main(string[] args)
{
Action p = myDelegate();
p();
p();
p();
Console.Read();
}
这段代码打印1 2 3,这是C#中闭包
标签:闭包,Console,C#,private,static,myDelegate,Action 来源: https://blog.csdn.net/qqqgg/article/details/88387734