I am creating a windows Form app In C#.
It is for a course I follow.
Now I have a
Cannot evaluate expression because a native frame is on the top of the call stack.
error. I have 10 buttons, with a for loop connected to it. The app has 10 buttons and each button show math tables (1 to 10) to Label2. The first button works like a charm. The other buttons give me the expression error.
Here I have the code for the first 2 buttons:
private void button1_Click(object sender, EventArgs e)
{
// Clear Label before execution
label2.Text = "";
// Loop
for (int n = 0; n < 11; n++)
{
int nn = n * 1;
label2.Text += "1x" + n + "=" + nn + "\r\n";
}
}
private void button2_Click(object sender, EventArgs e)
{
// Clear Label before execution
label2.Text = "";
// Loop
for (int n = 0; n < 11; n = n++)
{
int nn = n * 2;
label2.Text = "2x" + n + "=" + nn + "\r\n";
}
}
Can you guys help me out on this one? I already read through thread handling and such, but I am not that far yet into C#.
Edit: Got it to work with a change in the loop,
From
for (int n = 0; n < 11; n = n++)
To
for (int n = 0; n < 11; n++)