I need to write something that will get the start-up arguments and then do something for those start-up args, and I was thinking that switch would be good but it only accepts for ints and it has to be for a string
This isn't the actual code but I want to know how to make something like this work
namespace Simtho
{
    class Program
    {
        static void Main(string[] args)
        {
            switch (Environment.GetCommandLineArgs())
            {
                case "-i":
                    Console.WriteLine("Command Executed Successfully");
                    Console.Read;
                    break;
            }
        }
    }
}
                Environment.GetCommandLineArgs() returns an array of strings. Arrays cannot be switched on. Try iterating over the members of the array, like this:
namespace Simtho
{
    class Program
    {
        static void Main(string[] args)
        {
            foreach (string arg in Environment.GetCommandLineArgs())
            {
                switch (arg)
                {
                    case "-i":
                        Console.WriteLine("Command Executed Successfully");
                        Console.Read();
                        break;
                }
            }
        }
    }
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With