[問題] 請問一個全域變數的問題>"<
各位板友好:
我想請問一個很簡單的問題...
全域變數怎麼在改變後能保持他的值?
以下為例
public partial class _Default : System.Web.UI.Page
{
string a = "aaa";
protected void Button1_Click(object sender, EventArgs e)
{
a = "bbb";
Label1.Text = a;
}
protected void Button2_Click(object sender, EventArgs e)
{
Label2.Text = a;
}
}
按了button1後,label1會顯示 bbb
按了button2後,label2會顯示 aaa
我想請問有什麼方法可以在按了button1後,再按button2時
會讓label2 也能顯示bbb 呢?
總覺得這是很簡單的問題,但一直卡在這~"~
請各位幫忙解惑,謝謝:D
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.228.56.18
→
02/10 18:26, , 1F
02/10 18:26, 1F
→
02/10 18:27, , 2F
02/10 18:27, 2F
→
02/10 18:32, , 3F
02/10 18:32, 3F
→
02/10 23:08, , 4F
02/10 23:08, 4F