I like using NDesk.Options. You just have to add that source file to your project. It's really easy to use and has good documentation. The code would look like:
string server = null;
string database = null;
var p = new OptionSet () {
{ "S", v => server = v },
{ "D", v => database = v },
};
List<string> extra = p.Parse (args); // 'args' comes from Main (string [] args)
...
If you want automatic help to be generated, you would do:
string server = null;
string database = null;
var p = new OptionSet () {
{ "S", "Server name", v => server = v },
{ "D", "Database name", v => database = v },
{ "h", "Display help", v => { show_help = true; }},
};
List<string> extra = p.Parse (args); // 'args' comes from Main (string [] args)
if (show_help) {
Console.WriteLine ("Name of your program and brief description");
p.WriteOptionDescriptions (Console.Out);
Environment.Exit (0);
}
...