whats wrong with this code? It keeps giving me an "unreachable code detected " exception
public static int search(string Registration)
{
// this method will search for registration, if found it will return the index value , else it will return max value + 1
for (int x = 0; x < numOfRowsCars; x++)
{
reg = ds1.Tables["tblCars"].Rows[x][2].ToString();
MessageBox.Show(reg);
if (Registration == reg)
{
// Then return the index of the registration number
return x;
}
else
{
// Then return the max index + 1
return numOfRowsCars;
}
}
}