static void Main(string[] args)
{
int test = 1;
resetTest();
Console.Write(test); // Should be 0
}
static void resetTest()
{
test = 0;
}
Why doesn’t it work? How can I get it? (I don’t wanna to use int function and return to the variable) Now I have an error message which says that the variable test is undefined on the function resetTest.
because test is defined within the scope of your Main method.
You’ll need to move it outside that method for this to work.
Something like: