打開visual studio.net,建立C#項目,選擇windows窗體程序,
在界面上放置文本框、按鈕,如下圖所示。
交換按鈕對應的事件處理程序:
private void button1_Click(object sender, EventArgs e)
{
string s;
s = textBox1.Text;
textBox1.Text = textBox2.Text;
textBox2.Text = s;
}
點擊交換後: