Random Constructor
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Initializes a new instance of the Random class, using a time-dependent default seed value.
Assembly: mscorlib (in mscorlib.dll)
The distribution of the generated numbers is uniform; each number is equally likely to be returned.
The default seed value is derived from the system clock and has finite resolution. As a result, different Random objects that are created in close succession by a call to the default constructor will have identical default seed values and, therefore, will produce identical sets of random numbers. This problem can be avoided by using a single Random object to generate all random numbers. You can also work around it by modifying the seed value returned by the system clock and then explicitly providing this new seed value to the Random(Int32) constructor. For more information, see the Random(Int32) constructor.
The following example uses the default constructor to instantiate three Random objects and displays a sequence of five random integers for each. Because the first two Random objects are created in close succession, they are instantiated using identical seed values based on the system clock and, therefore, they produce an identical sequence of random numbers. On the other hand, the default constructor of the thirds Random object is called after a two-second delay caused by calling the Thread.Sleep method. Because this produces a different seed value for the third Random object, it produces a different sequence of random numbers.