top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Create random numbers in C#

+4 votes
198 views
Create random numbers in C#
posted Sep 18, 2014 by Muskan

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

Use the below program to generate random number in C#:

  class Program
    {
        static void Main()
        {
        // ... Create new Random object.
        Random r = new Random();
        // ... Get three random numbers.
        //     Always 5, 6, 7, 8 or 9.
        Console.WriteLine(r.Next(5, 10));
        Console.WriteLine(r.Next(5, 10));
        Console.WriteLine(r.Next(5, 10));
        }
    }

Output

5
7
6
answer Oct 3, 2014 by Amit Kumar Pandey
Similar Questions
+2 votes

Is there any VB.NET equivalent to the C# var keyword?

+4 votes

I want to Use collections and a Lambda expression instead of arrays!

+3 votes

How to Sign an Assembly with a Strong Name?

+7 votes

How to create your own controls?
Basic steps will be helpful.

...