Tuesday, March 13, 2012

switch statement less than ? more than ?

switch (Drivers) {case < 2:break;case >5:break;default: Console.WriteLine("Default case"); }
Can I use less than or more than in switch statement

like this

You cannot do this in C#, it's by design:http://msdn2.microsoft.com/en-us/vcsharp/aa336815.aspx

VB.NET can handle this though.


unfortunately no. you can do something like

case 1:

case 2:

do something;

break;

but < and > don't work

0 comments:

Post a Comment