L
Luc Bolly
Hi.
I would like to create a variable that allows me to count each pass through
a function. Ex.
class test {
static void main () {
DoFunction();
Environnment.Exit(0);
}
static void DoFunction() {
//static MyCounter=0; // this line should allow me to create
a variable that's create a compil time, initialized
// at compile time and
that will retain its value even when leaving the function
if ((MyCounter++%10)==0) {
Console.WriteLine(MyCounter);
}
}
}
I know that I can do the job with a variable external to the function, but I
used to work this way in older language (e.g. Clipper 5) and I founded it
useful. But I think that this construct is not allowed in C# ! Anyone having
an idea ?
Thanks
Luc
I would like to create a variable that allows me to count each pass through
a function. Ex.
class test {
static void main () {
DoFunction();
Environnment.Exit(0);
}
static void DoFunction() {
//static MyCounter=0; // this line should allow me to create
a variable that's create a compil time, initialized
// at compile time and
that will retain its value even when leaving the function
if ((MyCounter++%10)==0) {
Console.WriteLine(MyCounter);
}
}
}
I know that I can do the job with a variable external to the function, but I
used to work this way in older language (e.g. Clipper 5) and I founded it
useful. But I think that this construct is not allowed in C# ! Anyone having
an idea ?
Thanks
Luc