这应该不会太难,但我是 C# 新手,似乎无法修复它。如果用户希望将输入发送到数据库,我有一个 Prompt.Dialog.Choice 来确认一条消息。
我被困在 ChoiceReceivedAsync 中,我想在那里进行操作,无论用户是否回答“是”或“否”,但是我如何在 if-else 语句中调用这些答案?
这是相关的代码:
public enum booleanChoice { Yes, No }
public async Task StartAsync(IDialogContext context)
{
//var message = await result as IMessageActivity;
await context.PostAsync("Do you want you message to be sent?");
PromptDialog.Choice(
context: context,
resume: ChoiceReceivedAsync,
options: (IEnumerable<booleanChoice>)Enum.GetValues(typeof(booleanChoice)),
prompt: " ",
retry: "Please try again.",
promptStyle: PromptStyle.Auto
);
}
public async Task ChoiceReceivedAsync(IDialogContext context, IAwaitable<booleanChoice> result)
{
booleanChoice response = await result;
//Here's where I'm stuck:
//if (PromptDialog.Choice == "Yes"){//send the inputs to the databse}
//else (PromptDialog.Choice == "No"){//exit or enter the message again}
}
holdtom
相关分类