Difference between revisions of "Generating Random Numbers"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Created page with "=Code= <syntaxhighlight lang=c#> Random Rnd = new Random(); //This is the number generator Rnd.Next(); // gets you a random number between 0 & 1 Rnd.Next(10); // you can se...")
 
(No difference)

Latest revision as of 12:27, 6 February 2024

Code

Random Rnd = new Random(); //This is the number generator

Rnd.Next(); // gets you a random number between 0 & 1
Rnd.Next(10); // you can set an upper value (this will be 0 to 9)
Rnd.Next(1, 11); // you can set a lower and upper value (this will give 1 to 10)