John Liu .NET

View Original

Using ForEach and Anonymous Delegates.

//a piece of testing code, I think there's plenty more work to do.
private void Form1_Load(object sender, EventArgs e)
{
new List<Control>(new Control[] { this.button1, this.button2, this.button3, this.button4 }).ForEach(delegate(Control c) { c.Enabled = false; });
}