Tsallaka zuwa abun ciki
Justice Tech School

Random Numbers

Random.Shared gives numbers. Next(min, max) excludes max.

Example
var r = new Random(42);
int dice = r.Next(1, 7);
double d = r.NextDouble();
Console.WriteLine(dice >= 1 && dice <= 6);
Console.WriteLine(d < 1);

Exercise

Dice roll.

r.Next(1, )

Quiz Test

Is the max of Next included?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.