码迷,mamicode.com
首页 > Windows程序 > 详细

5.20 c#验证码练习

时间:2016-05-21 01:24:31      阅读:467      评论:0      收藏:0      [点我收藏+]

标签:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            Random ran = new Random();
            for (; ; )
            {
                string aa = "", bb = "";
                for (int l = 1; l <= 4; l++)
                {
                    int b = ran.Next(36);
                    string[] c = new string[36]
                 {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q",
                    "R","S","T","U","V","W","X","Y","Z","1","2","3","4","5","6","7"
                ,"8","9","0"};
                    aa = c[b];
                    bb += aa;
                }
                    Console.WriteLine("验证码是:" + bb);
                    Console.Write("请输入验证码");
                    string ma = Console.ReadLine();
                    ma = ma.ToUpper();
                    if (ma == bb)
                    {
                        Console.WriteLine("验证码输入正确");
                        break;
                    }
                    else
                    {
                        Console.WriteLine("输入有误请重新输入");
                    }
                    Console.ReadLine();

                }
            }
        }
    }

 

5.20 c#验证码练习

标签:

原文地址:http://www.cnblogs.com/suiyuejinghao123/p/5513848.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!