Windows desktop applications
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

PSHostUserInterface.PromptForChoice Method (String, String, Collection<ChoiceDescription>, Int32)

 

Updated: April 27, 2016

Applies To: Windows PowerShell

When overridden in a derived class, provides a set of choices that enable the user to choose a single option from a set of options.

Namespace:   System.Management.Automation.Host
Assembly:  System.Management.Automation (in System.Management.Automation.dll)

public abstract int PromptForChoice(
	string caption,
	string message,
	Collection<ChoiceDescription> choices,
	int defaultChoice
)

Parameters

caption
Type: System.String

The text that precedes (a title) the choices.

message
Type: System.String

A message that describes the choice.

choices
Type: System.Collections.ObjectModel.Collection<ChoiceDescription>

A Collection<T> of ChoiceDescription objects that describe each choice.

defaultChoice
Type: System.Int32

The index of the label in the choices parameter collection. These elements are displayed to the user as the default choices. To indicate no default choice, set to -1.

Return Value

Type: System.Int32

The index of the Choices parameter collection element that corresponds to the option that is selected by the user.

Exception Condition
HostException

The host can throw this exception when it cannot complete an operation.

NotImplementedException

If this method is not implemented, the host should throw a "not implemented" exception when it receives this call.

RuntimeException

The host can throw this exception when an error occurs while a command is running.

To provide a set of choices that allow the user to select multiple choices, implement the IHostUISupportsMultipleChoiceSelection interface.

Return to top

Community Additions

Show:
© 2016 Microsoft