EN
C# / .NET - generate list with 10 random numbers
6
points
Random.Next
method + List<T>
class example
public static class RandomUtils
{
public static List<int> generateList(int count)
{
Random random = new Random();
List<int> values = new List<int>();
for (int i = 0; i < count; ++i)
values.Add(random.Next());
return values;
}
}
Example:
List<int> values = RandomUtils.generateList(10);
foreach (int entry in values)
Console.WriteLine(entry);
Output:
490485272
864820117
1495826699
1735587819
842228568
570809745
1432321477
1467935517
1356326042
1627623506