我正在尝试制作一个简单的程序,用户尝试猜测 1 到 25 之间的数字,直到他们猜对了。我正在尝试将输入作为整数接收,以便我可以使用大于和小于符号。当我使用我在这个论坛的另一个答案中找到的命令时,它说有一个错误。我究竟做错了什么?
int score = 0;
int add = 1;
while (add == 1)
{
Console.WriteLine("Guess A Number Between 1 and 25");
string input = int.Parse(Console.ReadLine());
score += add;
if (input == 18)
{
Console.WriteLine("You Did It!");
Console.WriteLine("Your Score was " + score);
break;
}
else if (input > 25)
{
Console.WriteLine("Error.");
}
else
{
Console.WriteLine("Try Again. Score: " + score);
}
}