0

I am currently working on a console app which uses this command line parser library. Some of my option values should be Integers. So I was wondering if there is a way to specify these options in such a way that they only accept values of type int.

I already read through the documentary of the library but didn't find such functionality. But maybe I missed something.

Thank you for your help!

4

1 回答 1

2

显然,您所要做的就是将返回类型声明为 int。此示例在文档中:

[Option("l", "length", HelpText = "The maximum number of bytes to process.")]
  public int MaximumLength { get; set; };
// ...
}

The following will be accepted.
  GuideApp --length=99
  GuideApp -l12345
  GuideApp -l 555
The following will be rejected.
  GuideApp --length=a-string
  GuideApp -lsome_text
  GuideApp -l text.again
于 2016-01-22T11:48:50.850 回答