In C lang I could do something like this:
void f()
{
static int a = 0;
printf("%d\n", a);
a++;
}
Calling this function 3 times would result in:
0
1
2
Is it possible to use static variables like this in C# ?
In other words, to make, somehow, a variable inside a function persistent, until the next call.
I know I could use global variables, but I would like to keep my code cleaner and less confusing.
↧