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

Recommended Answers

All 2 Replies

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] + " ");
            }
            Console.ReadLine();
        }
    }
}

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-

commented: thank's for your help +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.