Command – Line Arguments in C#
Command line programs are the parameters that are passed at the beginning of program wihout asking for input from the program itself.
Example
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { // Global Variable (scope is visible to all block within {}) static void Main(string[] args) { Console.WriteLine("{0} command line arguments were specified:", args.Length); foreach (string arg in args) Console.WriteLine(arg); Console.ReadKey(); } } }
Command Line arguments are specified in Visual Studio as :
Step 1 : Right click project name > go to properties
Step 2: Select Debug and write some command line arguments in the text box as :
Now debug program, output will be
2 command line arguments were specified:
hello
program