Generate some unique numbers and put into array
<p>I'm trying to create a method that produces 10 unique random numbers, but the numbers are not unique, I get several duplicates! How can I improve the code to work as I want?</p>

<pre><code>        int[] randomNumbers = new int[10];

        Random random = new Random();

        int index = 0;

        do
        {
            int randomNum = random.Next(0, 10);
            if (index == 0)
            {
                randomNumbers[0] = randomNum;
                index++;
            }

            else
            {
                for (int i = 0; i &lt; randomNumbers.Length; i++)
                {
                    if (randomNumbers[i] == randomNum)
                        break;
                    else
                    {
                        randomNumbers[index] = randomNum;
                        index++;
                        break;
                    }
                }
            }
        }
        while (index &lt;= 9);

foreach (int num in randomNumbers)
            System.Console.Write(num + " ");
</code></pre>

<p>EDIT 2: I have corrected all errors now, but this code isn't working becuase the numbers are not unique! I have updated my code above to the latest version. I preciate some help to solve this! Thanks!</p>
