CommandLineArgumentAttributeDefaultValue Property

Gets or sets the default value to be assigned to the property if the argument is not supplied on the command line.

Definition

Namespace: Ookii.CommandLine
Assembly: Ookii.CommandLine (in Ookii.CommandLine.dll) Version: 4.2.0+a4d3631e4dcc0970081ed435288efdebc1325f83
C#
public Object? DefaultValue { get; set; }

Property Value

Object
The default value for the argument, or to not set the property if the argument is not supplied. The default value is .

Remarks

The DefaultValue property will not be used if the IsRequired property is , or if the argument is a multi-value or dictionary argument, or if the CommandLineArgumentAttribute attribute was applied to a method.

By default, the command line usage help generated by CommandLineParserWriteUsage(UsageWriter) includes the default value. To change that, set the IncludeDefaultInUsageHelp property to , or to change it for all arguments set the UsageWriterIncludeDefaultValueInDescription property to .

The default value can also be set by using a property initializer. When using the GeneratedParserAttribute attribute, a default value set using a property initializer will also be shown in the usage help, as long as it's a literal, enumeration value, or constant. Without the attribute, only default values set with the DefaultValue property are shown in the usage help.

See Also