【发布时间】:2017-10-12 04:50:51
【问题描述】:
我如何做到这一点,所以这个循环只有在按下“N”键时才会重复。目前按“Y”会退出,按“N”会清除并继续游戏,但如果按其他键也会继续?
while (cont)
{
theUI.InScreen();
goodBye.ClosingMessage();
Console.WriteLine("Do you want to exit Y/N?");
string exitInput = Console.ReadLine();
if (exitInput == "Y")
{
cont = false;
}
if (exitInput == "N")
{
cont = true;
Console.Clear();
}
}
【问题讨论】:
-
请包含当前代码
-
刚刚用当前代码更新了我的错误
标签: c# loops while-loop