+ 1

How can I generate a random number in C# ?

I want to generate a number a random number between 0 to 5 like when the random function is called first it wil give 2 and 3 when it is called again.

30th Oct 2021, 12:32 PM
Ashutosh Pattnaik
Ashutosh Pattnaik - avatar
1 ответ
+ 4
Random rnd = new Random(); for (int j = 0; j < 3; j++) { Console.WriteLine(rnd.Next(6)); //returns random integers >= 0 and < 6 } // Keep learning & happy coding :D
30th Oct 2021, 12:59 PM
SoloProg
SoloProg - avatar