I'm dealing with a lot of code that looks like this:
if (btnLeftDock.BackColor != SystemColors.ButtonFace)
{
btnLeftDock.BackColor = SystemColors.ButtonFace;
}
if (btnRightDock.BackColor != SystemColors.ButtonFace)
{
btnRightDock.BackColor = SystemColors.ButtonFace;
}
if (btnTopDock.BackColor != SystemColors.ButtonFace)
{
btnTopDock.BackColor = SystemColors.ButtonFace;
}
if (btnBottomDock.BackColor != SystemColors.ButtonFace)
{
btnBottomDock.BackColor = SystemColors.ButtonFace;
}
The only reason I can imagine to do this is that there is theoretically some winforms-specific overhead to setting control colors like this:
btnLeftDock.BackColor = SystemColors.ButtonFace;
btnRightDock.BackColor = SystemColors.ButtonFace;
btnTopDock.BackColor = SystemColors.ButtonFace;
btnBottomDock.BackColor = SystemColors.ButtonFace;
I think it's much easier to read, and I can't see any performance difference, but the original developer must have had some justification. (right?)