Share via


Random Constructor

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Initializes a new instance of the Random class, using a time-dependent default seed value.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Sub New
public Random()
public:
Random()
new : unit -> Random
public function Random()

Remarks

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.

.NET Framework Security

See Also

Reference

Random Class

Random Overload

System Namespace