This may be a stupid question, but I just want to somebody can give a better explanation.
I have a method defined as below:
private int Test(int i)
{
if (i < 0) return -1;
if (i == 0) return 0;
if (i > 0) return 1;
//return 0;
}
It gives me this error "not all code path return a value".
I thought I had 3 if statement, which could cover all the scenarios(i<0, i==0, i>0). So it should not show me this error.
Math.Sign(i).int iall scenarios are covered; as an excuse of the false alert, please, note that fordouble ithe warning is correct (double.NaNwill pass all threeifs)double.NaN.