生成无重复的随机数

 #region 生成随机数
        /// 
        /// 
        /// 
        private static int iCount;
        /// 
        /// 生成随机数
        /// 
        /// 
        public static string GenerateRandomNumber()
        {
            System.Threading.Interlocked.Increment(ref iCount);
            Random rnd = new Random(Guid.NewGuid().GetHashCode());
            return iCount.ToString().PadRight(4, '0') + rnd.Next(1, 10000).ToString().PadLeft(4, '0');
        } 
        #endregion

 

转载于:https://www.cnblogs.com/SmilePastaLi/p/9014951.html

你可能感兴趣的:(生成无重复的随机数)