Languages
[Edit]
EN

C#/.NET - random int

12 points
Created by:
Kate_C
19790

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.
Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join