标签:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication3 { 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(); Console.WriteLine("登陆结果:{0}",b); Console.WriteLine("登陆信息:{0}", msg); Console.ReadKey(); } /// <summary> /// 判断登陆是否成功 /// </summary> /// <param name="name">用户名</param> /// <param name="pwd">密码</param> /// <param name="msg">多余返回信息</param> /// <returns>登陆布尔值</returns> public static bool IsLogin(string name,string pwd,out string msg) { if(name == "admin" && pwd == "888888") { msg = "登陆成功"; return true; } else if(name=="admin") { msg = "密码错误"; return false; } else if(pwd =="888888") { msg = "用户名错误"; return false; } else { msg = "两者错误"; return false; } } } }
标签:
原文地址:http://www.cnblogs.com/blacop/p/5954907.html