Switch statments and < operators

Sorry if this is 101 basic question.
Can you have a switch statement that use “<” operators as I would like to write the code without if else statements if possible.

Switch (Var)
Case <1999:
\ do something
Case <2999
\ do something
ect ect

Please can you advise if this is possible and how to achieve this.

many thanks in advance

No, that is not valid syntax.

Some compilers support a case range,like case 100...199:

(what is 'ect'?)

Don’t try to use switch for things it isn’t designed for. Contrary to other languages like SQL, switch isn’t necessarily translated by the compiler to a set of if statements, thus what you want to do doesn’t work with switch. The correct syntax for your problem is:

if (var < 199) {
    // do something;
else if (var < 299) {
    // do something;
else if (var < 399) {
    // do something;
else {
   // do whatever

If formatted and indented properly, this is just as readable as a switch block.


thanks for the replies

else if statements it is