Switch statements in U# 1.X
Switch statements get compiled to a jump table if
the following conditions are met.
1. The input evaluates to an integer type (which enums doare a compile-time feature in U# and become integers at runtime)
2. The switch has at least 4 value cases and no more than 257 value cases
3. The case values in each case are in the range of `0 - 256`256 (inclusive)
This means you can have at most **257**257 explicit value cases and a `default`default case.
The cases can be declared in any order.order.
Example of a switchSwitch statement that will be compiledcompiles to a jump table:```cs
switch (inputValue)
{
case 256:
Debug.Log("256");
break;
case 0:
Debug.Log("0");
break;
case 2:
Debug.Log("2");
break;
case 123:
Debug.Log("123");
break;
default:
Debug.Log("Default value");
break;
}
```
Example of a switchSwitch statement that does not get compiledcompile to a jump table and instead becomes `if else if else if else ...````cs
switch (inputValue)
{
case -1:
Debug.Log("-1");
break;
case 257:
Debug.Log("257");
break;
default:
Debug.Log("Default value");
break;
}
```