How do I generate random numbers x times?

Nicole

How do I generate random numbers x times and write them as a string? I know how to generate random numbers:

Random rnd= new Random();
int num= rnd.Next(1, 51);

but how do I generate them x times and write them like "5, 15, 45"?

I hope my question is understandable.

Jan Feyen
var x = 10;
List<int> numbers = new List<int>();
Random random = new Random();
for (int i = 0; i < x; i++)
{
    numbers.Add(random.Next(1, 100));
}

Console.WriteLine(string.Join(", ", numbers));

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I generate random numbers in an array that add up to a defined total?

How do I generate random numbers in Dart?

How do I generate a random int number?

How do I generate random numbers with a mean in C++?

How should I generate random numbers for a genetic algorithm?

How do I generate non-repeating random numbers in a while loop? (Python 3)

How do I generate a vector of random numbers in a range?

I want to generate random numbers then do the addition operation on them

How do I generate random but unique numbers in python?

How do I generate random doubles in an Array?

How do I generate a random num::BigUint?

I'm trying to have a TextView generate a random number every 472 ms, five times. How would I use a loop to do this?

How do I generate infinite random numbers of pair of dice until they are equal?

How do i generate 2 random numbers, once within the range of 50 and 259, and once within 50 and 159?

How do I generate random number with a range X times in SQL SERVER

How do I generate a multidimensional NumPy array with random numbers with the dimension of another array whose dimension is not declared?

How do I generate thread-safe uniform random numbers?

How do I generate a random range of numbers within another range?

How do I generate different random numbers in a loop in C?

How do computers generate random numbers

How do I generate random numbers to fill in empty rows?

How do I generate a sequence of numbers like this?

How do I generate a random list in Python with duplicates numbers

How do I call my generate random numbers which has size 100 to simulation of playing dice 100 times

How do I generate a primary key that is not random?

How do i generate a random numbers for each integer in an array?

How do I generate random numbers but not repeating and within a certain range based on user input?

How do I generate a specific amount of random numbers?

How do I use random numbers to generate truly random results? ABS(CHECKSUM(NewID))) is not working

TOP Ranking

HotTag

Archive