Edit

Share via


ParseResult.GetRequiredValue Method

Definition

Overloads

GetRequiredValue<T>(Argument<T>)

Gets the parsed or default value for the specified required argument or throws.

GetRequiredValue<T>(Option<T>)

Gets the parsed or default value for the specified required option or throws.

GetRequiredValue<T>(String)

Gets the parsed or default value for the specified required symbol name, in the context of parsed command (not entire symbol tree).

GetRequiredValue<T>(Argument<T>)

Source:
ParseResult.cs

Gets the parsed or default value for the specified required argument or throws.

public:
generic <typename T>
 T GetRequiredValue(System::CommandLine::Argument<T> ^ argument);
public T GetRequiredValue<T>(System.CommandLine.Argument<T> argument);
member this.GetRequiredValue : System.CommandLine.Argument<'T> -> 'T
Public Function GetRequiredValue(Of T) (argument As Argument(Of T)) As T

Type Parameters

T

Parameters

argument
Argument<T>

The argument for which to get a value.

Returns

T

The parsed value or a configured default.

Exceptions

Thrown when required argument was not parsed or has no default value configured.

Applies to

GetRequiredValue<T>(Option<T>)

Source:
ParseResult.cs

Gets the parsed or default value for the specified required option or throws.

public:
generic <typename T>
 T GetRequiredValue(System::CommandLine::Option<T> ^ option);
public T GetRequiredValue<T>(System.CommandLine.Option<T> option);
member this.GetRequiredValue : System.CommandLine.Option<'T> -> 'T
Public Function GetRequiredValue(Of T) (option As Option(Of T)) As T

Type Parameters

T

Parameters

option
Option<T>

The option for which to get a value.

Returns

T

The parsed value or a configured default.

Exceptions

Thrown when required option was not parsed or has no default value configured.

Applies to

GetRequiredValue<T>(String)

Source:
ParseResult.cs

Gets the parsed or default value for the specified required symbol name, in the context of parsed command (not entire symbol tree).

public:
generic <typename T>
 T GetRequiredValue(System::String ^ name);
public T GetRequiredValue<T>(string name);
member this.GetRequiredValue : string -> 'T
Public Function GetRequiredValue(Of T) (name As String) As T

Type Parameters

T

Parameters

name
String

The name of the required Symbol for which to get a value.

Returns

T

The parsed value or a configured default.

Exceptions

Thrown when parsing resulted in parse error(s) or required symbol was not parsed or has no default value configured.

Thrown when there was no symbol defined for given name for the parsed command.

Thrown when parsed result can not be cast to T.

Applies to