模拟用户登录界面,要求用户输入账户和密码,直到用户输入账户“admin”,密码:“888888” 程序结束 否则要求用户一直输入
string userName, password;
while (true)
{
Console.WriteLine("请输入您的账户名:");
userName = Console.ReadLine();
Console.WriteLine("请输入您的密码:");
password = Console.ReadLine();
if(userName=="admin"&&password=="888888")
{
break;
}
Console.WriteLine("你输入的用户名或密码错误,请重新输入");
}
Console.WriteLine("登录成功");
Console.ReadKey();
break只作用与所在循环结构中,立即跳出循环体。