I have a lottery game where I can generate 1 set of 6 numbers.I am trying to generate two sets of 6 numbers but am unable to do so.
public static void LottoDraw()
{
int[] lotto = new int[6];
Random LottoNumbers = new Random();
for (int i = 0; i < lotto.Length; i++)
{
lotto[i] = LottoNumbers.Next(1, 47);
}
Array.Sort(lotto);
Console.WriteLine("Your Lotto Numbers are:");
for (int i = 0; i < lotto.Length; i++)
Console.WriteLine(lotto[i]);
Console.ReadLine();
}
I tried using a while loop but the variables "line1" and "line2" as seen here Generating 2 Random Numbers that are Different C# but kept generating errors. The method is being called in a switch. The larger set of code can be found here:
static void Main(string[] args)
{
int choice = 0;
do
{
DisplayMenu();
choice = int.Parse(Console.ReadLine());
switch (choice)
{
case 1:
LottoDraw();
break;
case 2:
EuroDraw();
break;
default:
Console.WriteLine("Please enter 1 for Lotto or 2 for EuroMillions");
break;
}
} while (choice != 2);
}
public static void LottoDraw()
{
int[] lotto = new int[6];
Random LottoNumbers = new Random();
for (int i = 0; i < lotto.Length; i++)
{
lotto[i] = LottoNumbers.Next(1, 47);
}
Array.Sort(lotto);
Console.WriteLine("Your Lotto Numbers are:");
for (int i = 0; i < lotto.Length; i++)
Console.WriteLine(lotto[i]);
Console.ReadLine();
}