Which code fragment is better to use when considering performance for the case of a switch with enum and int as the case parameter:
and.
switch ((ToolbarButton)BtnId)
{
case ToolbarButton.SHOWPROPERTYDIALOG:
OnShowProperties();
break;
case ToolbarButton.MOVETOFIRST:
OnFirstMessage();
break;
case ToolbarButton.MOVETOLAST:
OnLastMessage();
break;
}
AT.
switch (BtnId)
{
case (int)ToolbarButton.SHOWPROPERTYDIALOG:
OnShowProperties();
break;
case (int)ToolbarButton.MOVETOFIRST:
OnFirstMessage();
break;
case (int)ToolbarButton.MOVETOLAST:
OnLastMessage();
break;
}
source
share