Hmmm.
I couldn't figure out a C# version.
But for kicks, I tried to write a VB.net version, and it worked.
Private Sub SelectCaseTest()
Dim x As Int32 = 11
Dim y As Int32 = 0
Select Case x
Case Is < 10
y = 11
Case Is < 20
y = 21
Case Else
y = 999
End Select
Console.WriteLine(String.Format("{0}, {1}", x, y))
End Sub
Hmmmmmmmmmmmm.
This was all I could come up with, but I didn't try too long: But its not a
solution I know.
private static void SelectCaseTest()
{
int x = 11;
int y = 0;
switch (x)
{
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
y = 11;
break;
default:
y=999;
break;
}
Console.WriteLine(string.Format("{0}, {1}", x, y));
}
"graeme g" <gg*****@vrms.comwrote in message
news:uK****************@TK2MSFTNGP05.phx.gbl...
hi
how would i write the following in switch case statement:
if (x < 40)
y = 0;
else if (x < 65)
y = 1;
else if (x < 80)
y = 2;
else if (x < 90)
y = 3;
else if (x < 96)
y = 4;
else
y = 5;
is it easy or not possible?
thanks
g