标题:不知错哪
只看楼主
wanxingdai
Rank: 1
等 级:新手上路
帖 子:31
专家分:6
注 册:2010-9-21
结帖率:55.56%
已结贴  问题点数:10 回复次数:4 
不知错哪
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 密码登入
{
    class Program
    {
        static void Main(string[] args)
        {
            string id;
            string useid;
           //string usepw="";
            int count = 0;
            Console.Write("请注册帐号:\n");
            id = Console.ReadLine();
            Console.Write("请设定密码:\n");
            string pw =Console.ReadLine();
            Console.Clear();
            while (count<=3)
            {
                while (true)
                {
                    
                    Console.Write("请输入你的帐号:\n");
                    useid = Console.ReadLine();
                    Console.Write("请输入密码:\n");
                    ConsoleKeyInfo usepw = Console.ReadKey(true);
                    if (usepw.Key== ConsoleKey.Enter) break;
                    Console.Write("*");
                    usepw = usepw + pw.KeyChar.ToString();
                    if (useid == id && usepw.KeyChar.ToString() == pw)
                    {
                        Console.Write("登入成功!!!");
                    }
                    else
                    {
                        Console.Write("请重新登入:\n");
                        count++;
                        if (count%3==0)
                            break;
                    }
                    Console.Clear();
                    Console.Write("登入失败!!!");
                    Console.ReadKey();
                }
            }
        }
    }
}
搜索更多相关主题的帖子: 注册帐号 count 密码 
2011-03-21 22:42
qubo1982
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:1
帖 子:367
专家分:1132
注 册:2009-3-18
得分:0 
pw.KeyChar
pw是字符串,不包含KeyChar的定义
2011-03-22 08:50
fily1314
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
帖 子:166
专家分:1190
注 册:2007-7-18
得分:0 
usepw = usepw + pw.KeyChar.ToString();
pw里面没有KeyChar这东西
2011-03-22 08:52
wanxingdai
Rank: 1
等 级:新手上路
帖 子:31
专家分:6
注 册:2010-9-21
得分:0 
要怎么改啊
2011-03-22 13:11
qubo1982
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:1
帖 子:367
专家分:1132
注 册:2009-3-18
得分:10 
程序代码:
static void Main(string[] args)
        {
            string id;
            string useid;
            //string usepw="";
            int count = 0;
            Console.Write("请注册帐号:\n");
            id = Console.ReadLine();
            Console.Write("请设定密码:\n");
            string pw = Console.ReadLine();
            Console.Clear();
            while (count <= 3)
            {
                Console.Write("请输入你的帐号:\n");
                useid = Console.ReadLine();
                Console.Write("请输入密码:\n");
                string inputPass = string.Empty;
                while (true)
                {
                    ConsoleKeyInfo usepw = Console.ReadKey(true);
                    if (usepw.Key == ConsoleKey.Enter) break;
                    Console.Write("*");
                    inputPass += usepw.KeyChar.ToString();
                }
                if (useid == id && inputPass == pw)
                {
                    Console.Write("登入成功!!!");
                    return;
                }
                else
                {
                    Console.Write("请重新登入:\n");
                    count++;
                }
            }
            Console.Clear();
            Console.Write("登入失败!!!");
            Console.ReadKey();
}
2011-03-22 13:59



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-334354-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.785806 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved