# Why when creating List with random numbers the range is higher then what i set ?

I’m trying to make List with random numbers inside but that will not repeat them self.
So if there is a number 310 so it will not be more then once in the List.

I don’t see duplicated numbers but i see numbers that are not in the range.
The range is between 300 and 800 but i see in the List numbers like 906,960,834,1054

What i want to do is a List with none repeat numbers and in range between 300 and 800.

``````private void rndNumbers()
{
int Min = 300;
int Max = 800;
System.Random rnd = new System.Random();
randomNumbers = Enumerable.Range(Min, Max).OrderBy(x => rnd.Next()).Take(ObjectsToMove.Length).ToList();
}
``````

Take a look at the method signature of Enumerable.Range very closely (Enumerable.Range(Int32, Int32) Method (System.Linq) | Microsoft Learn). You’ll see that it takes two integers:

Enumerable.Range(int start, int count);

The first integer is the starting number. The second integer is how many numbers you want in your list.

So, to do what you’re looking to do, you’d want to call EnumerableRange(Min, Max - Min).OrderBy(…).etc…