Seed Value
The
Two different instances of the
In the above example, two different objects of the Random class are instantiated with the same seed value. So, they will generate the same random numbers.
By default, the seed value is time-dependent. In .NET Core, the default seed value is produced by the thread-static, pseudo-random number generator.
💬 If you appreciate this channel and want it to grow, why not support it: https://www.patreon.com/csharp1001notes
The
Random
class uses the seed value as a starting value for the pseudo-random number generation algorithm. By default, the Random
class uses the system clock to generate its seed value so that each instance of the Random
class can generate different random numbers.Two different instances of the
Random
class having the same seed value will generate the same random numbers, as shown below.In the above example, two different objects of the Random class are instantiated with the same seed value. So, they will generate the same random numbers.
By default, the seed value is time-dependent. In .NET Core, the default seed value is produced by the thread-static, pseudo-random number generator.
💬 If you appreciate this channel and want it to grow, why not support it: https://www.patreon.com/csharp1001notes