private void button1_Click(object sender, EventArgs e)
那 sender 到底是幹麻的
( object sender , EventArgs e ) 是C#裏面的事件響應的代碼
事件的激發控件,或叫事件源object型別的sender
EventArgs型別的e
我們可以做個簡單的測試
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = sender.ToString();
MessageBox.Show(((Button)sender).Name.ToString());
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = sender.ToString();
MessageBox.Show(((Button)sender).Name.ToString());
}