Now in my project, access to the command line arguments is organized as follows:

Application.Current.Properties["value"].ToString()) 

I believe that if you store the arguments in a static object, the access can be simplified, and it will look like this:

 MyProgramm.App.value 

I am wondering how to solve this problem more correctly?

    2 answers 2

    I usually do as follows.

    1. I define the Options class, which contains typed properties that correspond to the meaning of command line parameters.
    2. In the constructor, I parse the command line, and assign values ​​to the desired properties.
    3. To simplify the code, the need / unwantedness of the property and its possible default value is written in the custom attribute.
    4. The code that controls command line parsing and attribute interpretation is moved to an abstract base class for reuse. Access to attributes is done through reflection (since the command line is parsed once per application, the cost of reflection can be considered insignificant).

    This combines lightweight extensibility with the advantages of hard typing.

      In my opinion, it is better to leave the dictionary (extensibility). To simplify working with long names, I recommend using pseudonyms. In this case, it is better to use an enumeration, that is, an enumeration or class is created with static fields that are identifiers in the dictionary. After that, the code might look like this:

       // Обращение к словарю Application.Current.Properties{CmdLineKeys.Value].ToString()) 

      If the Application.Current.Properties field is often used in the same context, you should consider a local variable.