Q:

C# program to demonstrate the command line arguments

0

C# program to demonstrate the command line arguments

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

The source code to demonstrate the command line arguments is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.

//Program to demonstrate the command line arguments.

using System;

class Demo
{
    static void Main(string[] args)
    {
        Console.WriteLine("Command Line Arguments:");
        foreach (string arg in args)
        {
            Console.WriteLine("\t"+arg);
        }
    }
}

Compilation:

csc test.cs 

Execute:

test.exe India Pak China

Output:

Command Line Arguments:
	India
	Pak
	China

Explanation:

In the above program, we created a class Demo that contains the Main() method. The Main() method is the entry point for the program. Here we accessed the command line arguments and print them on the console screen. To pass command line arguments, we need to compile and run the program from the command line.

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now