I have the return statement for both if and else conditions within a foreach loop. Yet, I get this error. However, when I add a return statement after the loop ends, the error is resolved. That's fine! But what is a problem with the code below?
public static bool Function(List<String> list)
{
foreach (var item in list)
{
if(item != "test")
{
return false;
}
else
{
return true;
}
}
//return false
}