- 1

How to use random in C#?

- Random element in arrat choice. - Random integer from an interval choice.

20th Nov 2017, 11:08 AM
qas.rus
qas.rus - avatar
2 Answers
+ 1
You can use the Random class Declaration: Random random = new Random(); Use: random.Next(); You can also give it a minimum and maximum value like this: random.Next(3,7); This would give you a random number between 3 and 7 (inclusive) Hope this helped you with your question :P
20th Nov 2017, 12:52 PM
Nick
Nick - avatar
0
Š”Š»Ń Š½Š°Ń‡Š°Š»Š° сŠ¾Š·Š“Š°Ń‘Š¼ сŠ°Š¼ рŠ°Š½Š“Š¾Š¼. Random rnd=new Random(); // rnd - Š½Š°Š·Š²Š°Š½ŠøŠµ рŠ°Š½Š“Š¾Š¼Š° /* ŠæŠ¾Ń‚Š¾Š¼ Š¼Š¾Š¶ŠµŠ¼ ŠæрŠøсŠ²Š¾Šøть ŠæŠµŃ€ŠµŠ¼ŠµŠ½Š½Š¾Š¹ рŠ°Š½Š“Š¾Š¼Š½Š¾Šµ Š·Š½Š°Ń‡ŠµŠ½ŠøŠµ */ int a = rnd.Next(Š¢ŃƒŃ‚ Š²Š²Š¾Š“ŠøŠ¼ Š·Š½Š°Ń‡ŠµŠ½Šøя ŠæрŠøŠ¼ŠµŃ€ 1-2)
20th Nov 2017, 7:09 PM
WhiteWolf