This attribute helps you store multiple values using a single option. This is different than using OptionList which re-parses its single value.
Let's see a example of a target type.


class Options
    // ...
    [OptionArray("o", "output", HelpText = "The output files to generate.")]
    public string[] OutputFiles { get; set; };
    // ...

This allows the following.


GuideApp --output file0.out file1.out file3.out

GuideApp --output=file0.out file1.out file3.out file4.out

GuideApp -ofile0.out file1.out

Last edited May 14, 2012 at 8:49 PM by gsscoder, version 2


NirodhaSoftware Sep 19, 2014 at 2:47 PM 
This would not compile for me:
[OptionArray("o", "output", HelpText = "The output files to generate.")]
Only this would:
[OptionArray('o', "output", HelpText = "The output files to generate.")]
The shortName must be a character, not a string.

gsscoder May 14, 2012 at 8:50 PM 
It is a design decision. You can expose another property and dress up the array into list<of strings>.

amissico Mar 30, 2010 at 7:23 PM 
How come OptionArray's data type is a string array (string[]) and not a list of string (list<string>)?