: Hi
:
: I am new to thie C# world, but I have a question regarding the following exercise of the school (Lesson 3) Excersise 5 (Write a program that prints all the command line arguments).
:
: The code reads as follows:
:
: using System;
:
: namespace CSharpSchool
: {
: // program that prints all the command line arguments
: class CommandLineArgs
: {
: static void Main(string [] args)
: {
: for(int i=0; i<args.Length; i++)
: {
: Console.WriteLine
: ("The {0}th command line argument: {1}",
: i, args[i]);
: }
: }
: }
: }
:
: QUESTION:
:
: What am I suppose to see on the command screen?
: What do you mean by comand line argument? I cannot see at any point the display of "The {0}th command line argument: {1}". Instead I only can see the string "Press any key to continue".
:
: Thanks !!
:
It will print out the arguments supplied on the command line. For example:
appName.exe HeresAnArg Arg2
will output
The 0th command line argument: HeresAnArg
The 1th command line argument: Arg2
If no arguments are specified on the command line, the for loop will never execute and no ouput will be produced.
As an aside, you can see from the sample output that the string supplied to Console.WriteLine doesn't produce grammatically correct output (1th) and the second argument should be i+1 instead of i.