Get all the number between two numbers random

c#, random, shuffle

Solution

I would just do this:

var rnd = new Random();

var numbers =
    Enumerable
        .Range(1, 9)
        .OrderBy(x => rnd.Next())
        .ToArray();

An example result I got was:

Problem

I'm not sure, if this question is unique, but I couldn't find the answer. I want a good way to get numbers between 1 to 9 (including 9) randomly in C#, and I want to have all the 9 numbers. So I need a function that returns 9 numbers between 1 to 9 and I need every number exactly once. for example, the result would look like this: 4,3,2,6,9,7,1,5,8

Original source