You can use the inside out version of the Fisher-Yates shuffle
In C# it would look like:
private static int[] Shuffle(int n)
{
var random = new Random();
var result = new int[n];
for (var i = 0; i < n; i ++)
{
var j = random.Next(0, i + 1);
if (i != j)
{
result[i] = result[j];
}
result[j] = i;
}
return result;
}
It's good because you create and shuffle your array at the same time using a well known shuffle.
You'd want to reuse the same Random instance though.