Prompt Class
Provides methods for creating interactive yes/no prompts in console applications.
public static class PromptMethods
| Name | Description |
|---|---|
| YesNo(string, bool?) | Prompts the user with a yes/no question using standard Y/N labels. |
| YesNo(string, string, string, bool?) | Prompts the user with a yes/no question using custom labels. The prompt loops until the user provides a valid response. |
YesNo overloads
YesNo(string, bool?)
Prompt.csPrompts the user with a yes/no question using standard Y/N labels.
Parameters
questionstring- The question to display to the user.
defaultValuebool?- The default value to use if the user presses Enter without typing a response, or if the standard input is closed. If
null, the user must provide an explicit answer.
Returns
bool true if the user answered yes; otherwise, false.
Exceptions
EndOfStreamException- The standard input is closed and
defaultValueisnull.
YesNo(string, string, string, bool?)
Prompt.csPrompts the user with a yes/no question using custom labels. The prompt loops until the user provides a valid response.
Parameters
questionstring- The question to display to the user.
yesValuestring- The text representing a yes response (case-insensitive).
noValuestring- The text representing a no response (case-insensitive).
defaultValuebool?- The default value to use if the user presses Enter without typing a response, or if the standard input is closed. If
null, the user must provide an explicit answer.
Returns
bool true if the user answered yes; otherwise, false.
Exceptions
EndOfStreamException- The standard input is closed and
defaultValueisnull.