黑马程序员之C#编程基础学习笔记:用while break实现要求用户输入用户名和密码,只要不是admin,888888就一直提示要求重新输入。

--------------------------------------------------- 2345王牌技术员联盟、2345王牌技术员联盟、期待与您交流!---------------------------------------------------------


using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test14
{
      calss Program
      {
            static void Main(string[] args)
            {
                   while(true)
                   {
                          Console.WriteLine("请输入用户名");
                          string username = Console.ReadLine();
                          Console.WriteLine("请输入密码");
                          string password= Console.ReadLine();
                          if(username =="admin" && password == "888888")
                          {
                                   Console.WriteLine("登陆成功!");
                                   break;
                          }                                  
                      }
            }
      }

}


--------------------------------------------------- 2345王牌技术员联盟、2345王牌技术员联盟、期待与您交流!---------------------------------------------------------

你可能感兴趣的:(黑马程序员C#学习笔记)