C# Language Generating Random Numbers in C#

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9

Syntax

  • Random()

  • Random(int Seed)

  • int Next()

  • int Next(int maxValue)

  • int Next(int minValue, int maxValue)

Parameters

ParametersDetails
SeedA value for generating random numbers. If not set, the default value is determined by the current system time.
minValueGenerated numbers won't be smaller than this value. If not set, the default value is 0.
maxValueGenerated numbers will be smaller than this value. If not set, the default value is Int32.MaxValue.
return valueReturns a number with random value.

Remarks

The random seed generated by the system isn't the same in every different run.

Seeds generated in the same time might be the same.



Got any C# Language Question?