Question: Hi everyone I am trying to generate 6 different numbers on the same line in c# but the problem that i face is some of the numbers are repeating on the same line.Here is my code to

```
var rand = new Random();
List<int> listNumbers = new List<int>();
int numbers = rand.Next(1,49);
for (int i= 0 ; i < 6 ;i++)
    {
         listNumbers.Add(numbers);
         numbers = rand.Next(1,49);
    }

```

somewhere my output is

```
17 23 23 31 33 48

```

Answer: 
Make it a while loop and add the integers to a hashset. Stop the loop when you have six integers.
If you are not worried about the min, max, and range then you can use this.

```
 var nexnumber = Guid.NewGuid().GetHashCode();
        if (nexnumber < 0)
        {
            nexnumber *= -1;
        }

```