自定义生成随机数(同一时间内不重复)
private static char[] constant = { '0','1','2','3','4','5','6','7','8','9', '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' }; //随机数长度 public static string GenerateRandomNumber(int Length) { System.Text.StringBuilder newRandom = new System.Text.StringBuilder(36); Random rd = new Random(Guid.NewGuid().GetHashCode()); for (int i = 0; i < Length; i++) { newRandom.Append(constant[rd.Next(36)]); } return newRandom.ToString(); }