public static int GetInteger(string message)
        {
            string userInput        = String.Empty;
            int    intValue         = 0;
            int    numberOfAttempts = 0;

            do
            {
                if (userInput.ToLower() == "q" || userInput == "0")
                {
                    Environment.Exit(0);
                }
                if (userInput.ToLower() == "c")
                {
                    CampingCLI c = new CampingCLI();
                    Console.Clear();
                    c.RunCLI();
                }
                if (numberOfAttempts > 0)
                {
                    Console.WriteLine("Invalid input format. Please try again");
                }

                Console.Write(message + " ");
                userInput = Console.ReadLine();
                numberOfAttempts++;
            }while (!int.TryParse(userInput, out intValue));

            return(intValue);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            // Sample Code to get a connection string from the
            // App.Config file
            // Use this so that you don't need to copy your connection string all over your code!
            string     connectionString = ConfigurationManager.ConnectionStrings["CapstoneDatabase"].ConnectionString;
            CampingCLI cli = new CampingCLI(connectionString);

            cli.RunCLI();
        }