- 1
How to use random in C#?
- Random element in arrat choice. - Random integer from an interval choice.
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
0
ŠŠ»Ń Š½Š°ŃŠ°Š»Š° ŃŠ¾Š·Š“Š°ŃŠ¼ ŃŠ°Š¼ ŃŠ°Š½Š“Š¾Š¼.
Random rnd=new Random();
// rnd - Š½Š°Š·Š²Š°Š½ŠøŠµ ŃŠ°Š½Š“Š¾Š¼Š°
/* ŠæŠ¾ŃŠ¾Š¼ Š¼Š¾Š¶ŠµŠ¼ ŠæŃŠøŃŠ²Š¾ŠøŃŃ ŠæŠµŃŠµŠ¼ŠµŠ½Š½Š¾Š¹ ŃŠ°Š½Š“Š¾Š¼Š½Š¾Šµ Š·Š½Š°ŃŠµŠ½ŠøŠµ */
int a = rnd.Next(Š¢ŃŃ Š²Š²Š¾Š“ŠøŠ¼ Š·Š½Š°ŃŠµŠ½ŠøŃ ŠæŃŠøŠ¼ŠµŃ 1-2)