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(); } }}
浙公网安备 33010602011771号