O'Reilly logo

Visual C#® 2012: How to Program, Fifth Edition by Harvey Deitel, Paul Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8.13. Using Command-Line Arguments

On many systems, it’s possible to pass arguments from the command line (these are known as command-line arguments) to an app by including a parameter of type string[] (i.e., an array of strings) in the parameter list of Main, exactly as we’ve done in every app in the book. By convention, this parameter is named args (Fig. 8.23, line 7). When an app is executed from the Command Prompt, the execution environment passes the command-line arguments that appear after the app name to the app’s Main method as strings in the one-dimensional array args. The number of arguments passed from the command line is obtained by accessing the array’s Length property. For example, the command "MyApp a b" passes two command-line ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required