If you have an array of numbers (of any numeric type) and you need to shuffle it, you have two options.

Random Ordering

The first is to use the Random object to order the values randomly using LINQ, and project that into a new array.

Like so:

var numbers = Enumerable.Range(1, 25).ToArray();

var shuffled = numbers.OrderBy(n => Random.Shared.Next()).ToArray();

foreach (var number in shuffled)
{
  Console.Write($"{number} ");
}

This code will print something like this:

3 6 7 15 18 9 24 12 10 16 1 20 4 2 17 8 5 11 19 25 21 23 13 22 14 

Random Shuffle

This was such a common situation that the Random class introduced a Shuffle method from .NET 6.

For thread-safe use, the static Shared property also exposes the Shuffle method.

You use it like this:

// Shuffle in place

Random.Shared.Shuffle(numbers);

foreach (var number in numbers)
{
    Console.Write($"{number} ");
}

Unlike the previous technique, this one mutates the array in place.

This is simpler and easier to read than the previous technique.

This will also work with Span

TLDR

Use the Random.Shuffle method to shuffle arrays in place.

The code is in my GitHub.

Happy hacking!