这是我的代码如下。我做了它来检查名字并显示某些消息。当我在在线C#编译器上运行此代码时,它工作正常,但在本地运行时,它会立即跳到else
语句。
任何帮助表示赞赏。感谢
bool isUserWrong = true;
while (isUserWrong)
{
Console.Write("Insert your name");
string userInput = Console.ReadLine();
if (userInput.Equals("XYZ", StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine("{0} Sorry not you again!", userInput);
isUserWrong = true;
}
else if (userInput.Equals("ABC", StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine("{0} Youre the one!!!!", userInput);
isUserWrong = false;
}
else
{
Console.WriteLine("{0} Sorry wrong name :(", userInput);
isUserWrong = true;
}
Console.ReadLine();
}