Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3071975
  • 博文数量: 1412
  • 博客积分: 15478
  • 博客等级: 上将
  • 技术积分: 14938
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-23 16:08
文章存档

2016年(1)

2015年(17)

2013年(13)

2012年(103)

2011年(185)

2010年(261)

2009年(425)

2008年(363)

2007年(44)

分类:

2009-06-24 22:11:41

//练习二
//输入用户名和密码,如果正确就显示,如果错误,提示"错误"
//WriteLine编进去的固定句子,如:“请输入用户名”
//ReadLine要求临时输入的句子,如:“zhangjie”
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
    class Program
    {
        ///
        /// 主方法,入口
        ///

        ///
        static void Main(string[] args)
        {
            Console.WriteLine("请输入用户名和密码");//首先用一个变量接受:
            string userName = Console.ReadLine();//readLine中都空
            string userPassword = Console.ReadLine();
            if (userName == "zhangjie" && userPassword == "123456")
            {
                Console.WriteLine("用户名是:"+userName+"密码是:"+userPassword);
                Console.Read();
            }
            else if (userName != "zhangjie" && userPassword == "123456")
            {
                Console.WriteLine("用户名不正确!请确认!");
                Console.Read();
            }
            else if (userName == "zhangjie" && userPassword != "123456")
            {
                Console.WriteLine("密码不正确,请确认!");
                Console.Read();
            }
            else
            {
                Console.WriteLine("用户名和密码都不正确");
                Console.Read();
            }

        }
    }
}
 
 
阅读(595) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~