Skip to content
gsscoder edited this page Feb 27, 2013 · 12 revisions

Multi-Culture Support

The parser is culture-aware. The args[] array passed to ParseArguments<T>(...) is a string array, so when the parser loads data into target instance every string undergoes a conversion.

Now suppose you define a target class like this:

class Options {
  [Option('v', "value")]
  public double SomeValue { get; set; }
}

If your system use a dot as decimal separator and you type the following command line:

$ app -v 10,4

the parsing process will fail.

If you want that parsing occurs with a particular culture, just set desired CultureInfo in settings instance.

var parser = new CommandLine.Parser(with => with.ParsingCulture = new CultureInfo("it-IT"));

Please note that default behavior can change in future versions, so I suggest you to always explicit your culture preference.

Remarks: CommandLine.Parser.Default default singleton uses CultureInfo.InvariantCulture.