Top "Switch-statement" questions

In computer programming, a switch, case, select or inspect statement is a type of selection control mechanism used to invoke specific blocks of code based on variable contents.

error: switch quantity not an integer

I have researched my issue all over StackOverflow and multi-google links, and I am still confused. I figured the best …

c++ string switch-statement constant-expression
Is there any significant difference between using if/else and switch-case in C#?

What is the benefit/downside to using a switch statement vs. an if/else in C#. I can't imagine there …

c# .net switch-statement
C++ code for state machine

This was an interview question to be coded in C++: Write code for a vending machine: Start with a simple …

c++ design-patterns switch-statement state-machine idioms
How can I use ranges in a switch case statement using JavaScript?

How can I use ranges in a switch case statement using JavaScript? So, instead of writing code for each and …

javascript switch-statement intervals
Why switch is faster than if

Lots of Java books describe the switch statement as being faster than the if else statement. But I did not …

java switch-statement
How to make C# Switch Statement use IgnoreCase

If I have a switch-case statement where the object in the switch is string, is it possible to do an …

c# switch-statement
switch/case statement in C++ with a QString type

I want to use switch-case in my program but the compiler gives me this error: switch expression of type 'QString' …

c++ qt switch-statement qt4 qstring
Switch without break

I have some switch statement as shown below. Notice there is no break. Findbugs is reporting error on the second …

java switch-statement findbugs
Swift: Test class type in switch statement

In Swift you can check the class type of an object using 'is'. How can I incorporate this into a …

class swift switch-statement
PHP switch case more than one value in the case

I have a variable that holds the values 'Weekly', 'Monthly', 'Quarterly', and 'Annual', and I have another variable that holds …

php switch-statement case