EN
C# / .NET - generate array with 10 random numbers
14 points
xxxxxxxxxx
1
public static class RandomUtils
2
{
3
public static int[] generateArray(int count)
4
{
5
Random random = new Random();
6
int[] values = new int[count];
7
8
for (int i = 0; i < count; ++i)
9
values[i] = random.Next();
10
11
return values;
12
}
13
}
Example:
xxxxxxxxxx
1
int[] values = RandomUtils.generateArray(10);
2
3
foreach (int entry in values)
4
Console.WriteLine(entry);
Output:
xxxxxxxxxx
1
251131811
2
1423889290
3
691971575
4
975013585
5
1783948979
6
1657547893
7
1660547787
8
611183434
9
1679626510
10
1671582401