I've seen alot of command-line programs that take arguments, like ping google.com -t. How can I make a program like ping? I would like my program to take a number as an argument and then further use this number:
    For example:
geturi -n 1188
            Asked
            
        
        
            Active
            
        
            Viewed 154 times
        
    0
            
            
        - 
                    Take a look [here](http://stackoverflow.com/questions/491595/best-way-to-parse-command-line-arguments-in-c). Welcome to Stackoverflow. Unfortunately, this is not a [real question](http://meta.stackexchange.com/questions/145677/what-is-a-real-question) for here. Did you try anything so far? Please show your efforts first so that other people might help you out. Also, please read [FAQ](http://stackoverflow.com/help) and [How to Ask](http://stackoverflow.com/questions/how-to-ask) – kgdesouz Jul 03 '13 at 19:25
- 
                    I've searched on google but really found nothing on my own because I'm not entirely sure what keywords to search for I assume. – Æðelstan Jul 03 '13 at 19:33
2 Answers
1
            
            
        Just write a generic, console application.

The main method looks like the following snippet:
class Program
{
    static void Main(string[] args)
    {
    }
}
Your arguments are included in the args array.
 
    
    
        RLH
        
- 15,230
- 22
- 98
- 182
- 
                    Please up-vote and accept the answer if this was what you were looking for. Also, try to describe your situation a bit further in your question and, also, double-check that this question hasn't been asked. StackOverflow is a reasonably nice place, however, duplicates and poor questions are not tolerated. – RLH Jul 03 '13 at 19:47
0
            With a normal Console Application, in static void Main(string[] args), simply use the args. If you want to read the first argument as a number, then you simply use:
static void Main(string[] args)
{
    if (args.Length > 1)
    {
        int arg;
        if (int.TryParse(args[0], out arg))
            // use arg
        else // show an error message (the input was not a number)
    }
    else // show an error message (there was no input)
}
 
    
    
        Jashaszun
        
- 9,207
- 3
- 29
- 57
