public class Program { static void Main(string[] args) { Random random = new Random(); for (int i = random.Next(10); i < (random.Next(100) + i); i++) { Console.WriteLine(random.Next(100)); } } } code example
Example 1: c# generate random int in range
Random r = new Random();
int rInt = r.Next(0, 100);
int range = 100;
double rDouble = r.NextDouble()* range;
Example 2: obj random.next s#
Based on:
.NET 4.5
C# program that uses Random
using System;
class Program
{
static void Main()
{
Random r = new Random();
Console.WriteLine(r.Next(5, 10));
Console.WriteLine(r.Next(5, 10));
Console.WriteLine(r.Next(5, 10));
}
}
Output
5
7
6