C# Language Generating Random Numbers in C#

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

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?