What is “string[] args” in Main class for?

后端 未结 8 1501
眼角桃花
眼角桃花 2020-12-13 01:37

In C# the Main class has string[] args parameter.

What is that for and where does it get used?

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-13 02:16

    The args parameter stores all command line arguments which are given by the user when you run the program.

    If you run your program from the console like this:

    program.exe there are 4 parameters

    Your args parameter will contain the four strings: "there", "are", "4", and "parameters"

    Here is an example of how to access the command line arguments from the args parameter: example

提交回复
热议问题