Console program with multiple parameters

  .net, c++, windows

I am currently writing a console program using .NET Core for Windows and want to execute certain functions with parameters, for example program.exe /a /b. Unfortunately this does not work as I thought and therefore only the first specified parameter is executed, but not several in a row.

I have already tried the following and have tried to change it minimally several times:

        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Please give me one or more parameters to continue.");
                return;
            }

            var command = args[0];

            switch (command)
            {
                case "/?":
                    Console.WriteLine("Some help text ..");
                    break;
                case "/a":
                    Console.WriteLine("a");
                    break;
                case "/b":
                    Console.WriteLine("b");
                    break;
            }
        }

Any idea(s) for me?

Source: Windows Questions

LEAVE A COMMENT