I am using a switch and get a warning that code is unreachable.
If control goes to case 2 or 3, something will get execute then what is the issue?
I am using a switch and get a warning that code is unreachable.
If control goes to case 2 or 3, something will get execute then what is the issue?
While executing case "2"
and case "3"
, your function pointer will never reach break
statement because of goto
statements in if..else
conditions.
It is unreachable, the if statement above it will always redirect with the gotos
.
You could just refactor the logic into a simple if statement..
var cemValIsOne = hdnCEMStatus.Value == "1";
var cemIDIsZeroOrEmpty = hdmCEMID.Value == "" || hdmCEMID.Value == "0";
if(cemValIsOne || (!cemValIsOne && !cemIDIsZeroOrEmpty))
{
// case 1 code...
}
else
{
// case 0 true if statement code
}