I am trying to set a method called hasPassed() for a test score but can’t seem to do it.
The error I am getting is:
windowsformapplication1.student.HasPassed()’ not all code paths return a value
This is my code:
public int YearMark
{
get { return yearMark; }
set { yearMark = value; }
}
private bool hasPassed;
public bool HasPassed()
{
if (yearMark < 40)
{
hasPassed = false;
}
else
{
hasPassed = true;
}
}
You forgot to return the
boolvalue –