标签:
static void Main(string[] arr) { Console.WriteLine("请输入用户名"); string uname = Console.ReadLine(); Console.WriteLine("请输入密码"); string upwd = Console.ReadLine(); string msg; //out参数用于返值多个类型不一样,比如同时返回string ,bool,int bool bl = IsLogin(uname, upwd, out msg); Console.WriteLine("登录结果"+bl); Console.WriteLine("登录信息" + msg); Console.ReadKey(); } /// <summary> /// 判断登录是否成功 /// </summary> /// <param name="uname">用户名</param> /// <param name="upwd">密码</param> /// <param name="msg">返回的信息</param> /// <returns>返回登录结果</returns> public static bool IsLogin(string uname,string upwd,out string msg) { if (uname == "admin" && upwd == "888888") { msg = "登录成功"; return true; } else if (uname == "admin") { msg = "密码不对"; return false; } else { msg = "用户名不对"; return false; } }
标签:
原文地址:http://www.cnblogs.com/zywf/p/4491267.html