生成随机不重复数列表(C#)

        /// <summary>
        /// 生成随机不重复数列表
        /// </summary>
        /// <param name="count">不重复数数量</param>
        /// <returns>不重复数列表</returns>
        private static List<int> GetRandomList(int count)
        {
            List<int> list = new List<int>();
            int num = 0;
            Random rnd = new Random();
            for (int i = 0; i < count; i++)
            {
                do
                {
                    num = rnd.Next(010000, 1000000);
                } while (list.Contains(num));//                
                list.Add(num);
            }
            return list;
        }

 

posted @ 2013-02-28 11:46  沧海小小粟  阅读(349)  评论(0编辑  收藏  举报