The source code to demonstrate the use of GetCommandLineArgs() method of Environment class is given below. The given program is compiled and executed successfully.
using System;
class Sample
{
//Entry point of Program
static public void Main()
{
string[] cmdArg;
cmdArg = Environment.GetCommandLineArgs();
Console.WriteLine("Command Line Arguments:");
foreach (string arg in cmdArg)
{
Console.WriteLine("\t"+arg);
}
}
}
Here, we execute the above program using a command prompt to see all arguments passed on the command line.
Output:
D:\>Program.exe 123 ABCD
Command Line Arguments:
Program.exe
123
ABCD
Program:
The source code to demonstrate the use of GetCommandLineArgs() method of Environment class is given below. The given program is compiled and executed successfully.
Here, we execute the above program using a command prompt to see all arguments passed on the command line.
Output: