不接受提示选择,说明其无效 - C# Bot

Prompt choice is not accepted stating its not valid - c# Bot

正在我的机器人中创建一个选择字段,但不接受所选的选择。

下面是我的错误截图

Sample link这是供我参考的示例

代码片段

public enum Gender
    {
        [Terms("M","boy")]
         Male,
        [Terms("F","girl")]
         Female

    }
    public Gender? SelectGender;

在“Match user input using the Terms attribute”中,我们可以找到:

By default, the list of terms is generated by applying these steps to the field or value:

1. Break on case changes and underscore (_).

2. Generate each n-gram up to a maximum length.

3. Add "s?" to the end of each word (to support plurals).

您使用 Terms 属性来定义用于将用户输入与字段中的值相匹配的术语列表,这会覆盖此默认行为。您的术语列表中没有包含 "Male",因此当您输入 Male 作为值时会出现此问题。要解决此问题,您可以将 Male 添加到您的术语列表中。

public enum Gender
{
    [Terms("M", "boy", "Male")]
    Male,
    [Terms("F", "girl", "Female")]
    Female
}

此外,为了匹配更多的用户输入,您可以使用正则表达式。