我强烈建议使用NDesk.Options(文档)和/或Mono.Options(相同的API,不同的名称空间)。文档中的示例:
bool show_help = false;List<string> names = new List<string> ();int repeat = 1;var p = new OptionSet () { { "n|name=", "the {NAME} of someone to greet.", v => names.Add (v) }, { "r|repeat=", "the number of {TIMES} to repeat the greeting.n" +"this must be an integer.", (int v) => repeat = v }, { "v", "increase debug message verbosity", v => { if (v != null) ++verbosity; } }, { "h|help", "show this message and exit", v => show_help = v != null },};List<string> extra;try { extra = p.Parse (args);}catch (OptionException e) { Console.Write ("greet: "); Console.WriteLine (e.Message); Console.WriteLine ("Try `greet --help' for more information."); return;}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)