How can I obtain the named arguments from a console application in the form of a Dictionary?

前端 未结 4 774
走了就别回头了
走了就别回头了 2021-02-05 05:18

I have a console application called MyTool.exe

What is the simplest way to collect the named arguments passed to this console applicaiton and then to put them in a

4条回答
  •  你的背包
    2021-02-05 06:00

    I don't see why this code is bad? hova?

            var arguments = new Dictionary();
            foreach (var item in Environment.GetCommandLineArgs())
            {
                try
                {
                    var parts = item.Split('=');
                    arguments.Add(parts[0], parts[1]);
                }
                catch (Exception ex)
                {
                    // your error handling here....
                }
    

提交回复
热议问题