Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

40,026 questions

51,982 answers

573 users

How to generate random number in C#

2 Answers

0 votes
using System;
 
class Program
{
    static void Main()
    {
        Random rand = new Random(); 
        for (int i = 1; i <= 20; i++) { 
            Console.WriteLine(rand.Next(25, 35)); // 25 to 34
        } 
    }
}
 
 
 
 
/*
run:
 
33
25
33
34
32
26
26
25
32
25
27
29
28
28
27
33
26
28
32
33
 
*/

 



answered Oct 13, 2021 by avibootz
0 votes
using System;
 
class Program
{
    static void Main()
    {
        Random rand = new Random(); 
        for (int i = 1; i <= 20; i++) { 
            Console.WriteLine(rand.Next(28)); // 0 to 27
        } 
    }
}
 
 
 
 
/*
run:
 
17
16
21
14
11
18
2
10
8
16
6
0
3
13
8
11
5
18
1
25

*/

 



answered Oct 13, 2021 by avibootz

Related questions

1 answer 65 views
1 answer 107 views
1 answer 131 views
1 answer 101 views
1 answer 168 views
168 views asked Dec 10, 2021 by avibootz
1 answer 116 views
116 views asked Apr 22, 2017 by avibootz
...