I need to assign values to an IntArray with 1000 elements randomly. But the elements cannot be repeated. I used this code...
public int[] Numbers()
{
Random random = new Random();
int check;
for (int i = 0; i < numbers.Length; i++)
{
check = random.Next(0, 9999);
while (!numbers.Contains(check))
{
numbers[i] = check;
}
}
return numbers;
}
But then, an amount of numbers get the default values (0). What am I doing wrong ?