Good day, I have a code made by me in which I use a static variable to control certain actions in other forms, the detail is that the first time I use it it behaves as I expect, but from then on remains with the value 0 and (although I explicitly place it in 1, 2 or 3). It should be noted that the variable is of the integer type.
This is the code that gives a value depending on the button that is pressed in the program
private void Button_Click(object sender, RoutedEventArgs e)
{
opcion = 1;
Close();
}
As you can imagine here I am working on the same form in which it is declared.
the variable is defined as follows:
public static int opcion = 0;
When I clean and pass through the statement opcion = 1;
and I put the mouse on the variable this keeps showing 0.
Am I doing something wrong? try to put the volatile
modifier to see if the problem was not being able to access the variable, but it did not work.