Results 1 to 7 of 7

Thread: Retrieving Arguments for Command Line App

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2003
    Location
    When?!?!
    Posts
    108

    Retrieving Arguments for Command Line App

    I'm making a console window app with C#, but how do I retrieve arguments when the app runs?
    DannyJoumaa
    Advanced VB6 Programmer
    Intermediate-Advanced VB .NET Programmer
    Intermediate C# Programmer
    Intermediate Win32 Developer
    Beginner Mac OS X Developer
    Contact: [email protected]

    Favorite Sayings:
    "Every time you open your mouth, you prove your an idiot."
    "God is a programmer. Satan is a bug. Life is debugging."

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    By declaring array of string in the Main Method of your app . Like this :

    Code:
    public static Main(string[] args)  
    {
    'Your implementation here .
    }

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2003
    Location
    When?!?!
    Posts
    108
    lol, now I have another problem.... When I use in a void an object from one of my references, I get this:

    The type or namespace name 'xxxxx' could not be found (are you missing a using directive or an assembly reference?)

    I've referenced it, and I've even used the Using statement. No difference. Help is greatly appreciated,
    DannyJoumaa
    Advanced VB6 Programmer
    Intermediate-Advanced VB .NET Programmer
    Intermediate C# Programmer
    Intermediate Win32 Developer
    Beginner Mac OS X Developer
    Contact: [email protected]

    Favorite Sayings:
    "Every time you open your mouth, you prove your an idiot."
    "God is a programmer. Satan is a bug. Life is debugging."

  4. #4
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    post the code

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2003
    Location
    When?!?!
    Posts
    108
    got that prob fixed, but alas, another question (three of em)

    1. How do I clear the command window when developing a console app?

    2. If there were no arguments passed, how an I figre that out?

    3. If there was an argument passed, how do I parse it?
    DannyJoumaa
    Advanced VB6 Programmer
    Intermediate-Advanced VB .NET Programmer
    Intermediate C# Programmer
    Intermediate Win32 Developer
    Beginner Mac OS X Developer
    Contact: [email protected]

    Favorite Sayings:
    "Every time you open your mouth, you prove your an idiot."
    "God is a programmer. Satan is a bug. Life is debugging."

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Danny J
    1. How do I clear the command window when developing a console app?
    This has been posted here couple of times . Do a search .


    2. If there were no arguments passed, how an I figre that out?
    If (arg==null)
    do this



    3. If there was an argument passed, how do I parse it?
    You can handle the argument array as any other string array . Ex .

    foreach (string s in args)
    {
    s=s.remove(...,....)
    Console.WriteLine(s);
    }

    You have other options like (storing them in arraylist , or hastable ...etc)

  7. #7
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by Danny J
    got that prob fixed, but alas, another question (three of em)
    I'd suggest buying a book, alot of this will be answered.

    2. Check the size of the array
    3. Depends on what kind of arguements you want your program to except.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width