Switch Statement in C#
Posted
by pm_2
on Stack Overflow
See other posts from Stack Overflow
or by pm_2
Published on 2010-03-31T11:37:32Z
Indexed on
2010/03/31
11:43 UTC
Read the original article
Hit count: 302
c#
|switch-statement
Does anyone know if it's possible to include a range in a switch statement (and if so, how)?
For example:
switch (x)
{
case 1:
//do something
break;
case 2..8:
//do something else
break;
default:
break;
}
The compiler doesn't seem to like this kind of syntax - neither does it like:
case <= 8:
© Stack Overflow or respective owner