A
A
My compiler complains (probably for a good reason) that it cannot use local
variable in case statement.
But it is a mess if I declare it outside case. So I would like to keep it
local.
Is there a way to override this compiler behaviour or to write code
differently so that it doesn't trigger compiler error:
For example:
switch (condition)
{
case 0: // do something
break;
case 1: int i = 0; // This is where compiler says "case bypasses
init of local variable"
// use i here
break;
}
variable in case statement.
But it is a mess if I declare it outside case. So I would like to keep it
local.
Is there a way to override this compiler behaviour or to write code
differently so that it doesn't trigger compiler error:
For example:
switch (condition)
{
case 0: // do something
break;
case 1: int i = 0; // This is where compiler says "case bypasses
init of local variable"
// use i here
break;
}