Text menu and validation of the chosen item I am writing a c# console app that will take a user input from a list of selected options and do things based on the selected option. I have it working right now but just looking over it there seems that I should be able to shorten the code with other methods and make it perform a bit faster and more efficient but for some reason I just can't see it. Am I missing something or is this really the way to be doing this check? 

static void Main(string[] arguments)
{
    if (arguments.Length == 0)
    {
        Console.WriteLine("No run mode entered. Usage: JobSightMaintenance &lt;FirstRun | NightlyMaintenance&gt;");
        Console.WriteLine("Please select one of the following options to run:");
        printOptions();

        string userInput;
        bool isValidInput = true;

        do
        {
            userInput = Console.ReadLine();
            int selectedOption;

            try
            {
                selectedOption = int.Parse(userInput);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Invalid Option, please try again");
                printOptions();
                isValidInput = false;
                break;
            }

            switch (selectedOption)
            {
                case 1:
                    isValidInput = true;
                    break;

                case 2:
                    isValidInput = true;
                    break;

                default:
                    Console.WriteLine("Invalid Option, please try again");
                    printOptions();
                    isValidInput = false;
                    break;
            }
        }
        while (!isValidInput);
    }

    if (Debugger.IsAttached) { Console.ReadKey(); }
}

private static void printOptions()
{
    Console.WriteLine("1. Run Intial Data Import");
    Console.WriteLine("2. Nightly Maintenance");
}
Let’s suppose that perfectness is our goal :)

    static void Main(string[] args)
    {
        new Menu("Please select one of the following options to run:")
            .Option("Run Initial Data Import", () =&gt; Console.WriteLine("Importing..."))
            .Option("Nightly Maintenance", () =&gt; Console.WriteLine("I am the terror (that flaps in the night)!"))
            .Option("Exit")
            .Execute();
    }


Where:

public class Menu 
{
    public Menu(string prompt = "Please choose:")
        : this(prompt, Enumerable.Empty&lt;Option&gt;())
    {
    }

    Menu(string prompt, IEnumerable&lt;Option&gt; options)
    {
        Prompt = prompt;
        Options = options;
    }

    string Prompt { get; }
    IEnumerable&lt;Option&gt; Options { get; }

    public Menu Option(string name, Action action = null) =&gt;
        new Menu(Prompt, Options.Concat(new[] { new Option(name, action ?? (() =&gt; {})) }));

    public override string ToString() =&gt;
        Prompt + "\n\r" +
        string.Join("\n\r", Options.Select((o, i) =&gt; $"{i+1}. {o.Name}"));

    public void Execute() =&gt; Execute(Console.Out, Console.In);

    public void Execute(TextWriter writer, TextReader reader)
    {
        writer.WriteLine(this);
        int i;
        if (int.TryParse(reader.ReadLine(), out i) &amp;&amp; --i &gt;= 0 &amp;&amp; i &lt; Options.Count())
            Options.ElementAt(i).Execute();
        else
            Execute(writer, reader);
    }
}


And

class Option
{
    public Option(string name, Action action)
    {
        Name = name;
        Execute = action;
    }

    public string Name { get; }
    public Action Execute { get; }
}