Generating Random Numbers

From TRCCompSci - AQA Computer Science
Revision as of 11:27, 6 February 2024 by Admin (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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)