Monday, November 8, 2010

Eliminate if else statements for disabling and enabling controls

if (count > 0)
{
this.control.Enabled = false;
}
else
{
this.control.Enabled = true;
}



// this is 1 line compared to what we have above.
this.control.Enabled = (count <= 0);

No comments: