C#C
C#3y ago
Mek

✅ How To Return 2 numbers inside of an If/Else statement

using System;
using System.Threading;

namespace MeksMathGame
{
    class Program
    {

        public void Main(string[] args)
        {
            List<string> welcomeText = new()
            {
                "Welcome To Mek's Math Game!",
                "Some Rules Of Thumb To Remember While Playing:",
                "1) All Answers Are In The Form Of An Integer.",
                "2) If Your Division Answer Gives You A Decimal Like: 0.86, Then Your Answer Is 0",
                "3) This Game Has 5 Difficulties: Easy, Medium, Hard, Expert, and Master.",
                "4) None Of The Numbers You Will Encounter On Any Difficulty Will Go Higher Than 100.",
                "\n",
                "When You Are Ready To Begin, Enter 'Yes' To Start, Or 'No' To Exit."
            };

            for (int i = 0; i < welcomeText.Count; i++)
            {
                Console.WriteLine(welcomeText[i]);
            };

            string userReady = Console.ReadLine();

            if (userReady.ToLower() == "yes")
            {
                MainMenu mainMenu = new MainMenu();
                mainMenu.GameSelection();
            }
            else if (userReady.ToLower() == "no")
            {
                Console.WriteLine("Exiting Game. Please Wait.");
                Thread.Sleep(2000);
                Environment.Exit(0);
            }
            else
            {
                Console.WriteLine("Invalid Operation. Please Enter 'Yes' To Start The Game or Enter 'No' To Exit The Game.");
                Thread.Sleep(1000);
                Program program = new Program();
                program.Main();
            }
        }
    }
}
In my else part of the if/elif/else statement, I need to be able to start the program over, but where I referenced my class Program program = new Program(); and then called the function again program.Main(); <- this line is throwing an error CS7036: There is no argument given that corresponds to the required parameter 'args' of 'Program.Main(string[])' and I'm lost at how to start the program over, or how to give the user another chance to give their response. Thanks in advanced.
Was this page helpful?