I've started an algorithm for a program, and I've declared the array in method itself. However, when I reference the array inside the switch statement I get repetitive errors: Invalid expression term '{' and '{' expected and ';' expected Below is the code:
algorithm()
{
code .....
int[] interval;
more code....
switch (int.parse(lbl2.text))
{
case 1:
sInterval = {10, 20, 30, 40};
break;
case 2:
sInterval = { 50, 60, 70, 80};
break;
}
}
How do you fix this problem?
The correct syntax is new int[]{10, 20, 30, 40}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With