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

后端 未结 8 1502
眼角桃花
眼角桃花 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:28

    Further to everyone else's answer, you should note that the parameters are optional in C# if your application does not use command line arguments.

    This code is perfectly valid:

    internal static Program
    {
        private static void Main()
        {
            // Get on with it, without any arguments...
        }
    }
    

提交回复
热议问题