I am trying to make a loto number generator program that outputs 6 unique random numbers. I have bone this before with java using the collections.shuffle method. I cannot find such methods in c#. the only method I see available is the Random method. I tried to use this method in my code but it does not produce unique random numbers. sometimes is produces duplicat numbers in my loto number program. I have put a copy of my code here for you to have a look and have commented it for you so you can see what i am trying to do. Thanks.
static void Main(string[] args)
{
Random number = new Random();// object to randomize the arraylist ,LIST.
ArrayList list = new ArrayList();
for (int i = 1; i <= 49; i++) // Loop to populate the arraylist with int values from 1 to 49.
{
list.Add(i);
Console.WriteLine(number.Next(i)); // Output the contents of the arraylist in a randome order. (This produces duplicat numbers.
// I am trying to produce a loto number generator program. No duplicat numbers. Each random number must be unique.
}
for (int i = 1; i <= 6; i++)// This loop was going to be used to trip the ammount of random numbers displayed.
{