随机生成四位验证码

namespace 随机生成验证码
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string s = "abcdefghijklmnopqrstuvwxyz";
                string t = "李青用强力的回旋踢击退地方英雄,对目标以及被目标撞到的任何敌人造成伤害及击飞";
                string j = "1234567890";
                 Random r = new Random();
                 //int q = t.Length;
                // Console.WriteLine(q);
                 string x = s.Substring((r.Next(0,26)),1);   //从s中剪切单个字符
                 Console.Write(x);
                 string y = s.Substring((r.Next(0, 26)), 1);   //从s中剪切单个字符
                 string y1 = y.ToUpper();
                 Console.Write(y1);
                 string i = t.Substring((r.Next(0, 38)), 1); //从t中剪切单个字符
                 Console.Write(i);
                 string k = j.Substring((r.Next(0, 10)), 1); //从j中剪切单个字符 j.Substring(n,1);n代表从第几位开始
                 Console.WriteLine(k);
                Console.ReadLine();
            }
        }
    }
}

posted @ 2015-04-02 20:21  XCml  阅读(195)  评论(0编辑  收藏  举报