The enum constant reference cannot be qualified in a case label

I'll never get used to this... ever:

public enum STUPID { alpha, beta, gamma }

Where this...

switch(myStupid)
{
    case STUPID.alpha:
        break;
    case STUPID.beta:
        break;
    case STUPID.gamma:
        break;
}

Will give you this: "The enum constant STUPID.alpha reference cannot be qualified in a case label".

Just remove the qualifier, STUPID:

switch(myStupid)
{
    case alpha:
        break;
    case beta:
        break;
    case gamma:
        break;
}

Not very helpful when you're using Intellisense to complete your case statements and it just seems to be one of those things I forget almost every single time.

7/19/2008 | Comments (11) in C# | Java
Email