Command Line Parameters Sample

This sample shows how the command line can be accessed and two ways of accessing the array of command-line parameters.

This sample contains the source code for the Command Line Parameters Tutorial.

Building and Running the Sample Within Visual Studio

To build and run the Command Line Parameters samples

  1. Open the solution (CommandLine.sln).
  2. In Solution Explorer, right-click the CmdLine1 project and click Set as StartUp Project.
  3. In Solution Explorer, right-click the project and click Properties.
  4. Open the Configuration Properties folder and click Debugging.
  5. In the Command Line Arguments property, type the command-line parameters (see the tutorial for an example) and click OK.
  6. From the Debug menu, click Start Without Debugging.
  7. Repeat the preceding steps for CmdLine2.

Building and Running the Sample from the Command Line

To build and run the Command Line Parameters samples

  1. Use the Change Directory command to change to the CmdLine1 directory.

  2. Type the following:

    csc cmdline1.cs
    cmdline1 A B C
    
  3. Use the Change Directory command to change to the CmdLine2 directory.

  4. Type the following:

    csc cmdline2.cs
    cmdline2 John Paul Mary
    

See Also

Command Line Parameters Tutorial | Tutorial Samples