CommandLineArgumentConvertToArgumentTypeInvariant Method

Converts any type to the argument's ElementType.

Definition

Namespace: Ookii.CommandLine
Assembly: Ookii.CommandLine (in Ookii.CommandLine.dll) Version: 4.2.0+a4d3631e4dcc0970081ed435288efdebc1325f83
C#
public Object? ConvertToArgumentTypeInvariant(
	Object? value
)

Parameters

value  Object
The value to convert.

Return Value

Object
The converted value.

Remarks

If the type of value is directly assignable to ArgumentType, no conversion is done. If the value is a String, the same rules apply as for the ConvertToArgumentType(CultureInfo, String) method, using CultureInfoInvariantCulture. Other types will be converted to a string before conversion.

This method is used to convert the CommandLineArgumentAttributeDefaultValue property to the correct type, and is also used by implementations of the ArgumentValidationAttribute class to convert values when needed.

Exceptions

NotSupportedException The argument's ArgumentConverter cannot convert between the type of value and the ArgumentType.

See Also