我对 2 个文本框使用了相同的TextChanged
事件处理程序,所以它们是否有任何性能改进,或者只是可读性问题?
方法一
private void txtcode_TextChanged(object sender, EventArgs e)
{
//Some code
}
private void txtname_TextChanged(object sender, EventArgs e)
{
//Some code
}
方法二
private void txt_TextChanged(object sender, EventArgs e)
{
TextBox txtbx = (TextBox)sender;
switch (txtbx.Name)
{
case "txtname":
//Some code
break;
case "txtcode":
//Some code
break;
default:
break;
}
}