EN
C#/.NET - generate random int
12
points
In C#/.NET is possible to generate random int in few ways.
1. Random
int
example
Random random = new Random();
int value = random.Next();
Console.WriteLine(value);
Output:
1069169069
2. Random
int
with max value example
Random random = new Random();
int value = random.Next(100);
Console.WriteLine(value);
Output:
58
Note: random value will be from 0 to 99 (100-1).
3. Random
int
from range example
Random random = new Random();
int value = random.Next(10 + 1, 100 + 1);
Console.WriteLine(value);
Output:
34
Note: random value will be from 11 to 100.