This code works as needed for the task, only the if tree will be too large, what can be redone so as not to load hundreds of if tests? According to the task: (Windows Form application - C #) when on the cmd command line we access the application via the / h command, command 1 is executed, when we issue the 1 2 3 command to the / h / s / e commands, and the application should not be displayed. Only when you click on the application form should be loaded.
Code in Program.cs
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var form = new Form1(); if (args.Contains("/h")) { form.Check1(); } if (args.Contains("/s")) { form.Check2(); } if (args.Contains("/e")) { form.Check3(); } else if (args.Contains("/h") == false && (args.Contains("/s")) == false && (args.Contains("/e") == false)) { Application.Run(new Form1()); } }
var form = Form1()before checking the conditions, do you need only one form? - vp_arthargs.Contains("/h") == falsedoes, and others ignore or forbid commands ... I can only understand patterns, so it’s hard to navigate. - Vitokhv