static void Main(string[] args)
{
string user, pwd, msg;
Console.WriteLine(\”请输入用户名:\”);
user = Console.ReadLine();
Console.WriteLine(\”请输入密码:\”);
pwd = Console.ReadLine();
bool b = IsLogin(user, pwd, out msg);
Console.WriteLine(msg);
Console.Read();
}
/// <summary>
/// 判断登录是否成功
/// </summary>
/// <param name=\”user\”>输入的用户名</param>
/// <param name=\”pwd\”>输入的密码</param>
/// <param name=\”msg\”>多余的返回登录信息</param>
/// <returns>返回是否登录成功</returns>
public static bool IsLogin(string user, string pwd, out string msg)
{
if (user == \”admin\” && pwd == \”888888\”)
{
msg = \”登陆成功\”;
return true;
}
else if (user == \”admin\”)
{
msg = \”密码错误\”;
return false;
}
else if (pwd == \”888888\”)
{
msg = \”用户名错误\”;
return false;
}
else {
msg = \”未知错误\”;
return false;
}
}
C#学习.模拟登录界面
未经允许不得转载:爱站程序员基地 » C#学习.模拟登录界面