[問題] 廣域變數定義
我如果把變數定在public class form1下面
這種情況下我Buttom1_click的指令會把值再重新寫到變數裡面
這樣我下次運算的時候值會亂跳
要怎樣才可以避免這種情況~請各位大大幫忙
我超新手!!剛開始學!
namespace N_
{
public partial class Form1 : Form
{
public int N , c, a = 1, sum;
public Form1()
}
private void button1_Click(object sender, EventArgs e)
}
this.textBox3.Text = ("1");
N = Convert.ToInt32(this.textBox1.Text);
while (a <= N)
{
c = Convert.ToInt32(this.textBox3.Text);
sum = a * c;
this.textBox3.Text = (sum).ToString();
a++;
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 125.228.253.86
→
05/22 13:01, , 1F
05/22 13:01, 1F
→
05/22 13:10, , 2F
05/22 13:10, 2F
→
05/22 13:11, , 3F
05/22 13:11, 3F
→
05/22 13:11, , 4F
05/22 13:11, 4F
→
05/23 02:01, , 5F
05/23 02:01, 5F
→
05/23 02:02, , 6F
05/23 02:02, 6F