提示用户输入用户名,然后再提示输入密码,如果用户名是“admin”并且密码是“88888”,
则提示正确,否则,如果用户名不是admin还提示用户用户名不存在,如果用户名是admin则提示密码错误.
//输入用户名
Console.WriteLine("请输入用户名:");
string userName = Console.ReadLine();
//输入密码
Console.WriteLine("请输入密码:");
int pass = Convert.ToInt32(Console.ReadLine());
if (userName == "admin" && pass == 88888)
{
Console.WriteLine("正确");
}
else if (userName != "admin")
{
Console.WriteLine("用户名不存在");
}
else Console.WriteLine("密码错误");
Console.ReadKey();



网友评论