Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用接受的答案以最佳方式解析 C# 中的命令行参数?作为你的例子,我怎样才能让'r'或'repeat'选项只可选地取一个值而不是REQUIRE它,如果没有提供该值,我该如何设置一个默认值?谢谢!
显然你可以这样做:
{ "r|repeat:", "the number of {TIMES} to repeat the greeting.\n" + "this must be an integer.", (int v) => repeat = v ?? 1 },
如果未提供该值,则默认值为 1。