>Hi,
>
>How can I do something like this in C#?
>
>
switch (myVar)
> {
> case (1 || 2):
> // Do some stuff
> break;
>
> default:
> break;
> }
>
>I get an error: Operator '||' cannot be applied to operands of type 'int' and 'int'
>
>Or does the switch statement only allow one possibility per case?
You can do it like this
switch (myVar)
{
case 1:
case 2:
break;
default:
break;
}
Gregory