.NET console app help

Soldato
Joined
1 Feb 2006
Posts
8,188
I'm putting together a simple console app in C# to do some basic stuff against SharePoint.

I have a main method which accepts some args. I call the app from a batch file i.e.

Code:
MyApp arg1 arg2 arg3

How could I go about making the tool to accept switches i.e.
Code:
MyApp -o AddUser -username "someuser" -useremail "someemail"

Basically what I don't know is how can I have the -o, -username, -useremail type switches built in to my code?

My code so far is very basic and start with...
Code:
static int Main(string[] args)
{
    //the args are separated by comma in my batch file
    string something = args[0];
    string something1 = args[1];
    string something2 = args[2];

    //code to use the args goes here

}

Any ideas?
 
This is what you need.

It takes all string[] arguments passed to your ctor and returns you a nice dictionary object you can use interrogate to see what was specified.
 
Thanks guys. Been a while since I have done any coding but looks like that material is some heavy night time reading.

Will have a look.
 
Back
Top Bottom