C#生成10位随机码包含数字大小写字母

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace RandomStringDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            string chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 
            Random randrom = new Random((int)DateTime.Now.Ticks);
 
            string str = "";
            for (int i = 0; i < 10; i++) {
                str += chars[randrom.Next(chars.Length)];
            }
 
            Console.WriteLine(str);
            Console.Read();
        }
    }
}
posted @ 2017-10-18 16:37  cbinqin  阅读(3497)  评论(0编辑  收藏  举报