[Solved] Error message ‘not all code path return a value’ appears in a class

[ad_1]

your code can be simplified:

    public bool CheckStudents(int students)
    {
        if(this.firstyear && students < 150)
        {
            return true;
        }

        return false;
    }

Remember, the function returns as soon as the any return statement is hit. You don’t need to check for every case, only the cases where you won’t return false.

[ad_2]

solved Error message ‘not all code path return a value’ appears in a class