在CI可以做到
void foo() {
static int c = 0;
printf("%d,", c);
c ++;
}
foo();
foo();
foo();
foo();
Run Code Online (Sandbox Code Playgroud)
它应该打印 0,1,2,3
C#中有等价物吗?
就像是:
class C
{
private static int c = 0;
public void foo()
{
Console.WriteLine(c);
c++;
}
}
Run Code Online (Sandbox Code Playgroud)