Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# Switch Syntax
Message
 
 
To
04/02/2011 10:07:54
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01498737
Message ID:
01498741
Views:
55
>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?

As I recall, this version only allows one value.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform