I have enums in one of my windows application like below:
private enum ModificationType
{
Insert = 0,
Update = 1,
Delete = 2
}
I have below function:
private void UpdateDatabaseTransactions(ModificationType _modifcationType)
{
int modType = (int)_modifcationType;
if (modType == 0) {...}
if (modType == 1) {...}
if (modType == 2) {...}
also I can use it like below:
if (_modifcationType == ModificationType.Insert) {...}
if (_modifcationType == ModificationType.Update) {...}
if (_modifcationType == ModificationType.Delete) {...}
}
What is the difference between the both and in which scenarios I have to typecast the value and use, is there any performance boosters in using any one of the above, or both are same?