O'Reilly logo

C# Primer Plus by Klaus Michelsen

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

Command Line Arguments

Recall that the Main() method is special in that it is automatically invoked by the .NET runtime when program execution commences. It holds another special feature—it is possible to enter data (here called arguments) into the Main() method from the console window (or a Windows application) when the program initially is started. To enable this functionality, we need to include a formal parameter of type reference-to-array-object of base type string in the method header of Main() as in the following:

public static void Main(string [] args)

where the array variable, as per tradition, is called args.

Passing arguments from the console into Main() can now be done simply by typing these next to the text you usually type (typically ...

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