mardi 10 février 2015

Unreachable expression code detected within IF statement

I have the following IF statement:



if ((SectorA.IsNull == false && SectorA.Value > 0)
&& (SectorB.IsNull == true || SectorB.Value == 0))
{
SectorC.Value = SectorA.Value;
}
else if ((SectorA.IsNull == true || SectorA.Value == 0) //Unreachable code here
&& (SectorB.IsNull == false && SectorB.Value > 0))
{
SectorC.Value = SectorB.Value;
}


The 'SectorA.Value == 0' part of the 'else if' is stated as being unreachable but I can't see why. It's simply a reverse of the first part of the if statement, which is apparently ok.


As the first part of the IF statement checks SectorA with an '&&' then surely it's still valid to check for '0' in the else if?


Basically I need to check 2 'sectors'. If 1 contains a value (greater than 0) whilst the other doesn't then use that sector value.


Aucun commentaire:

Enregistrer un commentaire