c# random function code example
Example 1: c# random int
Random rnd = new Random();
int number = rnd.Next(1, 10);
Example 2: c# random number
int random_number = new Random().Next(1, 10)
Example 3: how to generate random numbers in c#
int randomNumber = UnityEngine.Random.Range(1, 100);
Example 4: 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