I have a program which works with arrays and at some point I have to check if a lsit of values are inside an array, the function that does this takes about 70% of the program CP
Instead of shuffle, you can generate the possible values in a list and take values at random positions. That way you can start using the items even before the whole row is generated:
IEnumerable RandomRange(int count) {
var random = new Random();
var list = new int[count];
for (int i = 0; i < count; i++) list[i] = i;
while (count > 0) {
var i = random.Next(count);
yield return list[i] ;
list[i] = list[--count];
}
}
sample use:
foreach(var item in RandomRange(10))
// ...