I don't believe you can use switch with a string.
From the documentation, "Expression of the switch operator must be of integer type."
ok, I know it. But how declare variable x?
int x; // ok, but x = number..
string x; // wrong
Can you write declare variable x, please? (x= one char value, at this sample up
Like this . . . .
int x; switch(x) { case 1: Print("CASE A"); break; case 2: case 3: Print("CASE B or C"); break; default: Print("NOT A, B or C"); break; }
;-) but in the sample is for x as number and I would like code for x (char) case 'A':
x as number - I understand,
x as char 'A' (sample code from documentation) - don´t understand
;-) but in the sample is for x as number and I would like code for x (char) case 'A':
x as number - I understand,
x as char 'A' (sample code from documentation) - don´t understand
;-) but in the sample is for x as number and I would like code for x (char) case 'A':
x as number - I understand,
x as char 'A' (sample code from documentation) - don´t understand
All you need to understand is what is written in the documentation . . . "Expression of the switch operator must be of integer type."
I would agree that the example is unfortunate and misleading. x can't be a string . . .
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
how do I declare variable x in this code:
int or string is wrong. Compiler return error. Variable x will be value one char A, B, C, D, etc.
Thank zou.