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.

cmd.exe doesn't terminate when using a .bat file

[Context: I'm trying to create a shortcut to a .bat file with a relative "Start in" path as roughly described …

shell windows-7 cmd switch-statement desktop-shortcut
How to shorten switch case block converting a number to a month name?

Is there a way to write this on fewer lines, but still easily readable? var month = ''; switch(mm) { case …

javascript date switch-statement date-format
Using strings in switch statements - where do we stand with C++17?

Every one of us has (probably) had the childhood dream of writing: switch(my_std_string) { case "foo": do_stuff(); …

c++ switch-statement stdstring c++17 string-literals
Using {} in a case statement. Why?

What is the point with using { and } in a case statement? Normally, no matter how many lines are there in …

c++ switch-statement
Using 'switch' with strings in resource file

I have a bunch of strings in my resource(.resx) file. I am trying to directly use them as part …

c# .net switch-statement embedded-resource
value of integral type expected switch with dynamic parameter

Just out of curiosity. If I have the following Code public static string Format(dynamic exception) { switch (exception.GetType().ToString()) { …

c# exception switch-statement dynamic-variables object-to-string
javascript switch using intervals

Can I use intervals in a switch statement? Like switch (parseInt(troops[i])) { case <10: editbox.style.fontSize = "13px"; break; …

javascript switch-statement intervals
c switch and jump tables

It is my understanding that a switch statement in c/c++ will sometimes compile to a jump table. My question …

c++ switch-statement jump-table
Using strstr inside a switch php

I just cannot think of the code. I have waay too many if statments which I want to change to …

php switch-statement strstr
C# 7.0 case pattern matching on generic parameter

Is there a reason for not being able to handle a generic variable by the type pattern? Please consider the …

c# generics switch-statement c#-7.0