正在建一个测试模型,中间有个需求是这样的:时间字符串(模型中唯一)
20130322 -> 需自动随机5位长数字串eg: 30687
20130323 -> 需自动随机5位长数字串eg: 27139现在用Guid生成的那种都是绝对不重复的,不满足这个需求。
求教...

解决方案 »

  1.   

    目前使用唯一随机的是这个:
    public static int GetRandomInt(int A, int B)
            {
                return new Random(Guid.NewGuid().GetHashCode()).Next(A, B + 1);
            }
      

  2.   

    random是伪随机数,提供相同的种子,顺序生成的随机数就是一样的。
      

  3.   

      static void Main(string[] args)
            {            for (int i = 0; i < 5; i++)
                {
                    Random rd = new Random(0);
                    for (int j = 0; j < 11; j++)
                    {
                        Console.Write(" " + rd.Next(0, 10));
                    }
                    Console.WriteLine("");
                }
                Console.Read();
            }伪随机,原来是这样的。明白了。呵呵