I tried the following but it didn't work. The error in compiling says it expected each case to be an integer but I have strings such as "USD", "EUR", etc.
Can switch handle strings? If not I can always go back to if/else if/else statements...
|
Switch Operator
Compares the expression value with constants in all the case variants and passes control to the operator that corresponds to the expression value. Each variant of case can be marked with an integer constant, a literal constant or a constant expression. The constant expression can't contain variables or function calls. Expression of the switch operator must be of integer type.
I tried the following but it didn't work. The error in compiling says it expected each case to be an integer but I have strings such as "USD", "EUR", etc.
Can switch handle strings? If not I can always go back to if/else if/else statements...
Convert to ASCII char, then you can use switch, but using nested ifs -= alot of if within if - will do the trick.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I tried the following but it didn't work. The error in compiling says it expected each case to be an integer but I have strings such as "USD", "EUR", etc.
Can switch handle strings? If not I can always go back to if/else if/else statements...