There are numerous solutions to this problem. For completeness and to provide the alternative if someone desires I'm adding this answer for two useful classes in my google code library.
The first is ArgumentList which is responsible only for parsing command line parameters. It collects name-value pairs defined by switches '/x:y' or '-x=y' and also collects a list of 'unnamed' entries. It's basic usage is discussed here, view the class here.
The second part of this is the CommandInterpreter which creates a fully-functional command-line application out of your .Net class. As an example:
using CSharpTest.Net.Commands;
static class Program
{
static void Main(string[] args)
{
new CommandInterpreter(new Commands()).Run(args);
}
//example ‘Commands’ class:
class Commands
{
public int SomeValue { get; set; }
public void DoSomething(string svalue, int ivalue)
{ ... }
With the above example code you can run the following:
Program.exe DoSomething "string value" 5
-- or --
Program.exe dosomething /ivalue=5 -svalue:"string value"
It's as simple as that or as complex as you need it to be. You can review the source code, view the help, or download the binary.