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: 
I've switched your for loop with a do...while loop and set the stopping condition on the list count being smaller then 6. 
This might not be the best solution but it's the closest to your original code.

```
List<int> listNumbers = new List<int>();
do
    {
        int numbers = rand.Next(1,49);
        if(!listNumbers.Contains(number)) {
            listNumbers.Add(numbers);
        }
    } while (listNumbers.Count < 6)

```
**Paste the below in the class as a new method**

```
    public int randomNumber()
    {
        var random = new Random();
        int randomNumber = random.Next(10000, 99999);
        return randomNumber;
    }

```

***And use the below anywhere in the tests wherever required***

```
var RandNum = randomNumber();

driver.FindElement(By.CssSelector("[class='test']")).SendKeys(**RandNum**);

```