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.
Aucun commentaire:
Enregistrer un commentaire