C# - Arguments for application

后端 未结 5 421
野趣味
野趣味 2021-01-27 08:02

How can I make it so when there are arguments added to the end of the program name it does a specific method or whatever?

Also, is there a name for this?

Example

5条回答
  •  时光取名叫无心
    2021-01-27 08:55

    These are called command-line arguments. There's a good tutorial on MSDN on how to use them.

    This example should get you started:

    class TestClass
    {
        static void Main(string[] args)
        {
            // Display the number of command line arguments:
            System.Console.WriteLine(args.Length);
        }
    }
    

提交回复
热议问题