Thread: I thought it was argS. Plural.

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    127

    I thought it was argS. Plural.

    As in more than one. I'm trying to parse CL options using

    Code:
    static void Main(string[] args)
    {
        foreach(string arg in args)
        {
    	System.Console.WriteLine(arg);
        }
    }
    So I run my program

    MyProgram "Arg1" "Arg2" "Arg3"

    Output:

    Arg1" Arg2 Arg3

    Notice the odd ". Am I assuming something I shouldn't be?

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    You must be doing something goofy. You're not even getting them on individual lines? WriteLine() should be appending a newline for you. Using your program I get:
    Code:
    >CommandLineArgs.exe "arg1" "arg2" "arg3"
    arg1
    arg2
    arg3
    Check the way you're passing your args again.
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    127
    The only thing that could be considered goofy is arg1 is really a windows path like "C:\some path\here\"

    Hah, ok I see. Since I was passing a directory in, I ended the string with a \ which escaped the ".
    Last edited by homer_3; 04-01-2011 at 12:05 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointer confusion
    By Blackroot in forum C++ Programming
    Replies: 11
    Last Post: 09-12-2007, 12:44 AM
  2. Replies: 2
    Last Post: 10-24-2005, 01:32 PM
  3. Replies: 1
    Last Post: 06-29-2004, 05:23 PM
  4. Command line args
    By lpmrhahn in forum C Programming
    Replies: 5
    Last Post: 04-12-2004, 09:54 PM
  5. confused with args for event handler~
    By black in forum C# Programming
    Replies: 3
    Last Post: 03-03-2004, 03:25 AM