public enum Animal
{
Dog = 1,
Cat = 2,
Cow = 3
}
int animalID = 4;
if ((Animal)animalID == Animal.Dog) // does not throw exception
animalID can t be casted to Animal
.
Why don t I get InvalidCastException
when casting enum to integer fails?