any body tell me what is command line argument with example.
Thank's in advance.

7 Years
Discussion Span
Last Post by ashishkumar008

Simply we can say, command line argument is that argument which is passed to Main method.
Example is:

using System;
using System.Collections.Generic;
using System.Text;

namespace CommandLineArgument
    class Program
        static void Main(string[] args)
            for (int i = 0; i < args.Length; i++)
                Console.Write(args[i] + " ");

Steps are:

1. start visual studio and create new project.
2. Go to Project menu and select the properties. Located in last(last option)
3. select Debug tab in next screen.
4. now you can see Command line arguments: option within Start option. Here you can pass your argument.

i already attached two image snapshot.

and second method is using command prompt.
Steps are:
1. open command prompt of visual studio.
2. go to the file location by using cd foldername command.
3. compile your project by using csc filename.cs
4. now type the filename, give one space and then type your argument and hit enter.

I hope this useful for you.
useful link-

Edited by __avd: Added [code] tags.

Votes + Comments
thank's for your help
Attachments 1st_step.png 95.25 KB 2nd_step.png 94.58 KB
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.