我在表单上有很多标签,每个标签都使用不同的参数调用相同的方法(属于标签文本/名称)。这是代码:
//"res" is an array
private void label1_Click(object sender, EventArgs e)
{
checkresult(res[0]);
}
private void label2_Click(object sender, EventArgs e)
{
checkresult(res[1]);
}
private void label3_Click(object sender, EventArgs e)
{
checkresult(res[2]);
}
private void label4_Click(object sender, EventArgs e)
{
checkresult(res[3]);
}
private void label5_Click(object sender, EventArgs e)
{
checkresult(res[4]);
}
private void label6_Click(object sender, EventArgs e)
{
checkresult(res[5]);
}
private void label7_Click(object sender, EventArgs e)
{
checkresult(res[6]);
}
private void label8_Click(object sender, EventArgs e)
{
checkresult(res[7]);
}
private void label9_Click(object sender, EventArgs e)
{
checkresult(res[8]);
}
我只想通过为所有标签定义一种方法来精确我的代码。我该怎么做?