samedi 21 octobre 2017

return; not "closing" the method

I have a void method with the arguments: int i, Boolean HasAnnouncements and the following if-else statement:

if (now >= springSemester && now <= endSpringSemester&&i>=12)
    {
        PageToGo = go.ToArray()[i]-1;
        return;
    }else
    {
        if (HasAnnouncements==true)
        {
            PageToGo = go.ToArray()[i] + 1;
            return;
        }            
    }
    PageToGo =  go.ToArray()[i];

My problem is that return; statement isnot closing the method! For example: if now >= springSemester && now <= endSpringSemester&&i>=12 is false and HasAnnouncements==true is true pageto go will take its value and after return; will run PageToGo = go.ToArray()[i]; ... What am i missing here???

Aucun commentaire:

Enregistrer un commentaire