Which code snippet is better to use when considering the performance for the switch case with enum and int as the case parameter:
A.
switch ((ToolbarButton)BtnId)
{
case ToolbarButton.SHOWPROPERTYDIALOG:
OnShowProperties();
break;
case ToolbarButton.MOVETOFIRST:
OnFirstMessage();
break;
case ToolbarButton.MOVETOLAST:
OnLastMessage();
break;
}
B.
switch (BtnId)
{
case (int)ToolbarButton.SHOWPROPERTYDIALOG:
OnShowProperties();
break;
case (int)ToolbarButton.MOVETOFIRST:
OnFirstMessage();
break;
case (int)ToolbarButton.MOVETOLAST:
OnLastMessage();
break;
}
Once compiled,
EnumsAREInts.There is No difference what-so-ever in the MSIL.