ArgsReader.ReadOption method

Reads the value of the specified option, if any.

public string? ReadOption(string name)
parameter description
name The name of the specified option.

Return Value

The specified option if it was found on the command line; null otherwise.


exception condition
ArgumentNullException name is null.
ArgumentException One of the names is empty.
ArgsReaderException The argument that must follow the option is missing.


If the option is found, the method returns the command-line argument after the option and both arguments are removed. If ReadOption is called again with the same name, it will return null, unless the same option appears twice on the command line.

To support multiple names for the same option, use a vertical bar (|) to separate them, e.g. use n|name to support two different names for a module option.

Single-character names use a single hyphen, e.g. -n example. Longer names use a double hyphen, e.g. --name example.

See Also