Reputation: 8762
My switch case has an error:
Error: The label case 1 already occurs in this switch statement
switch (myEnum)
{
case MyEnum.EnumOne:
break;
case MyEnum.EnumTwo:
break;
case MyEnum.EnumThree: //The error line
break;
default:
break;
}
What is the problem?
Upvotes: 0
Views: 1130
Reputation: 8762
Just figure it out:
My enum definition of EnumThree
is wrong:
public enum MyEnum
{
EnumOne = 0,
EnumTwo = 1,
EnumThree = 1,
}
Iv'e edited MyEnum
definition to (thanks @dmitry-bychenko):
public enum MyEnum
{
None = 0
EnumOne = 1,
EnumTwo = 2,
EnumThree = 3,
}
And it worked.
Upvotes: 3