A
case
can contain only a single constant expression. The comma is not giving you two different cases that lead to the same code, it is evaluating both expressions and then throwing away the first one.
See:
Comma Operator[
^]
The
case
specifies a value which the expression in the
switch
must exactly match, there's no way to perform any analysis to the matching.
I think I'm sure the only way to accomplish this is to violate the constraint on not separating them:
switch(Colors)
{
case BLUE | RED:
case BLUE | GREEN:
{
OutputDebugString("OK");
break;
}
}