I was using the switch statement in C# and I realised, though the variable passed in the switch statement is an enum, the switch statement does not throw an error for case 0, but does throw an error for case 1,2,3... I was wondering why is it so. I know how to use enums with the switch case and I don't need help with that, I want to know why isn't it throwing an error with 0. Since 0 is an integer.
Here is the code, and this compiles without any errors. MathOperator is an enum.
public double Test5(double num1, double num2, MathOperator op)
{
double answer=0;
switch (op)
{
case 0:
{
break;
}
}
return answer;
}
Thank you for answering my question!