C#C
C#2y ago
TuckBuckk

Can't declare variables not in main?

All of my variables in Main and playLottery have the error line underneath them. How come
//Lab Exercise 6.3.2024 Problem 1
//Author: Tucker Sopha

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Problem_1
{
    class Program
    {
        List<int> yourWhiteBalls = new List<int>();
        int yourPowerBall;

        List<int> winningWhiteBalls = new List<int>();
        int winningPowerBall = -1;
        bool win = false;
        int numberOfPlays;
        Random r = new Random();
        static void Main(string[] args)
        {
            //Declare variables



            //Generate 5 numbers
            for (int i = 0; i < 5; i++)
            {
                yourWhiteBalls.Add(r.Next(1, 70));
            }
            //Sort the list
            yourWhiteBalls.Sort();
            //Pick the PowerBall
            yourPowerBall = r.Next(1, 27);


            //Print the picks and the PowerBall
            printLottery(yourWhiteBalls, yourPowerBall);

           
        }
        static void playLottery()
        {
            while (!win)
            {
                for (int i = 0; i < 5; i++)
                {
                    winningWhiteBalls.Add(r.Next(1, 70));
                }
                winningWhiteBalls.Sort();
                winningPowerBall = r.Next(1, 27);

                if (yourPowerBall == winningPowerBall)
                {
                    continue;
                }

                for (int i = 0; i < 5; i++)
                {

                }
            }
        }
    }
}
image.png
Was this page helpful?