我不断收到标题中命名的错误,但似乎无论如何都会返回 l 的值。这里有什么问题?如果没有变化,我有一个 else 语句来处理 out l :
public int validate(int zip, int i, out int l)
{
if ((zip < 10000) || (zip > 99999))
{
Console.WriteLine("Input not accepted. Zips are 6-digits long.");
error = true;
}
else {
listzip[i] = zip;
error = false; }
for (int g = 1; (g <= (i - 1)); g++)
{
if (listzip[i] == listzip[g])
{
Console.WriteLine("Repeated zip detected, please re-enter.");
if (!error) error = true;
} else error = false;
}
if (error)
{
l = i--; // forces a step back if an error was detected
}else l = i;
}