共用方式為


PSHostUserInterface.PromptForChoice Method

Definition

Presents a dialog allowing the user to choose an option from a set of options.

public:
 abstract int PromptForChoice(System::String ^ caption, System::String ^ message, System::Collections::ObjectModel::Collection<System::Management::Automation::Host::ChoiceDescription ^> ^ choices, int defaultChoice);
public abstract int PromptForChoice (string caption, string message, System.Collections.ObjectModel.Collection<System.Management.Automation.Host.ChoiceDescription> choices, int defaultChoice);
abstract member PromptForChoice : string * string * System.Collections.ObjectModel.Collection<System.Management.Automation.Host.ChoiceDescription> * int -> int
Public MustOverride Function PromptForChoice (caption As String, message As String, choices As Collection(Of ChoiceDescription), defaultChoice As Integer) As Integer

Parameters

caption
String

Caption to precede or title the prompt. E.g. "Parameters for get-foo (instance 1 of 2)"

message
String

A message that describes what the choice is for.

choices
Collection<ChoiceDescription>

An Collection of ChoiceDescription objects that describe each choice.

defaultChoice
Int32

The index of the label in the choices collection element to be presented to the user as the default choice. -1 means "no default". Must be a valid index.

Returns

The index of the choices element that corresponds to the option selected.

Applies to

See also