Skip to content

Confirm

Confirm プロンプトはユーザーに Yes/No の質問をします。

基本的な使い方

csharp
var answer = Prompt.Confirm("Are you ready?");
Console.WriteLine($"Your answer is {answer}");

デフォルト値付き

csharp
var answer = Prompt.Confirm("Are you ready?", defaultValue: true);
Console.WriteLine($"Your answer is {answer}");

パラメータ

パラメータ説明
messagestringユーザーに表示するメッセージ
defaultValuebool?ユーザーが入力せずに Enter を押した場合のデフォルト値

Options クラス

csharp
var answer = Prompt.Confirm(new ConfirmOptions
{
    Message = "Are you ready?",
    DefaultValue = true
});

Fluent API

csharp
using Sharprompt.Fluent;

var answer = Prompt.Confirm(o => o.WithMessage("Are you ready?")
                                  .WithDefaultValue(true));

Released under the MIT License.