EN
C# / .NET - generate list with 10 random numbers
6 points
xxxxxxxxxx
1
public static class RandomUtils
2
{
3
public static List<int> generateList(int count)
4
{
5
Random random = new Random();
6
List<int> values = new List<int>();
7
8
for (int i = 0; i < count; ++i)
9
values.Add(random.Next());
10
11
return values;
12
}
13
}
Example:
xxxxxxxxxx
1
List<int> values = RandomUtils.generateList(10);
2
3
foreach (int entry in values)
4
Console.WriteLine(entry);
Output:
xxxxxxxxxx
1
490485272
2
864820117
3
1495826699
4
1735587819
5
842228568
6
570809745
7
1432321477
8
1467935517
9
1356326042
10
1627623506