方法返回多个值参数Out使用的方法

  string str;
            Console.WriteLine("请输入用户名");
            string user = Console.ReadLine().ToString();
            Console.WriteLine("请输入密码");
            string pass = Console.ReadLine().ToString();
            Program p = new Program();
            bool b=p.Panduan(user,pass,out str);
            if (b)
            {
                Console.WriteLine(str);
            }
            else
            {
                Console.WriteLine(str);
            }
            Console.ReadKey();
        }
        private bool Panduan(string user,string pass,out string result)
        {
            bool a;
            if (user=="admin" && pass=="123456")
            {
                result = "登录成功";
                a = true;
                
            }
            else
            {
                result = "登录失败";
                a = false;
               
            }
            return a;
        }

  

原文地址:https://www.cnblogs.com/xiaowie/p/9564181.html