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


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.

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