foreach (Control control in this.Controls)
{
if (control is Button)
{
if(control.Name == "button1")
control.Enabled = false;
}
}
方法二:
Label[] lb = new Label[3] { label1, label2, label3 };
for (int i = 0; i < 3; i++)
{
lb[i].Text = "label*" + i.ToString();
}