Here i have a problem please help me.
I had made and console application named "input.csproj".On debug it created "input.exe" and the following line of code i have used.

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

namespace input
{
    class Program
    {
        static void Main(string[] args)
        {
            string a=Console.ReadLine();
            Console.WriteLine(a);
            Console.ReadKey();
        }
    }
}

Now the the problem is that i want to use it in "cmd" to give it input.Like...


1. Open the cmd.exe
2. "c:\input.exe" "Someinput"
3. it only display the output which is "someinput".


please tell me what i have to do?I will be very thankful to you.


Thankx in advance....

Well when you enter command line arguments they are stored in the args array..

static void Main(string[] args) //"someinput" would be stored in here.
        {
            string a=Console.ReadLine(); //this is wrong..Console.ReadLine() reads input from the user when enter is pressed
            Console.WriteLine(a);
            Console.ReadKey();
        }
static void Main(string[] args)
        {
            foreach (string arg in args)
            {
               Console.WriteLine(arg);
             }
        }

You would be better off using a foreach loop to print each argument to the console. The simple loop above will just cycle through each argument you enter.

http://msdn.microsoft.com/en-us/library/ttw7t8t6(v=vs.80).aspx

take a look at that and it explains the foreach loop.

commented: Thanks +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.