using System;
namespace out参数的使用
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入账户");
string name = Console.ReadLine();
Console.WriteLine("请输入密码");
string pwd = Console.ReadLine();
string msg;
bool b =IsLogin(name,pwd,out msg);
Console.WriteLine("登陆结果:{0}",b);
Console.WriteLine("登陆信息:{0}",msg);
Console.ReadKey();
}
public static bool IsLogin(string name, string pwd, out string msg)//方法栏
{
if (name == "admin" && pwd == "888888")
{
msg = "登陆成功";
return true;
}
else if (name == "admin")
{
msg = "密码输入错误";
}
else if (pwd == "888888")
{
msg = "账号输入错误";
return false;
}
else
{
msg = "未知错误";
return false;
}
}
}
}