在FormFlow,BotFramework中使用List <t>时缺少第一个选项

时间:2017-04-26 08:00:31

标签: c# botframework

我通过查看指南https://docs.botframework.com/en-us/csharp/builder/sdkreference/forms.html撰写FormFlow演示,效果很好。 在演示"Simple Sandwich Bot"Sandwich.cs中,有枚举:

public List Toppings;

public List Sauce;

public enum ToppingOptions
{
    Avocado, BananaPeppers, Cucumbers, GreenBellPeppers, Jalapenos,
    Lettuce, Olives, Pickles, RedOnion, Spinach, Tomatoes
};

public enum SauceOptions
{
    ChipotleSouthwest, HoneyMustard, LightMayonnaise, RegularMayonnaise,
    Mustard, Oil, Pepper, Ranch, SweetOnion, Vinegar
};

代码运行时,选择ToppingOptionsSauceOptions, 缺少第一个选项。这是一个错误吗? a picture to show the result

1 个答案:

答案 0 :(得分:1)

首先,在示例中,他们将列表声明为&#39; ToppingOptions&#39;值,仅使用List<ToppingOptions>而不是List,如果它仍然不起作用,请尝试更改枚举的第一个值并将其设置为1,并将其他值保持为

public enum ToppingOptions
{
    Avocado = 1, BananaPeppers, Cucumbers, GreenBellPeppers, Jalapenos,
    Lettuce, Olives, Pickles, RedOnion, Spinach, Tomatoes
};

public enum SauceOptions
{
    ChipotleSouthwest = 1, HoneyMustard, LightMayonnaise, RegularMayonnaise,
    Mustard, Oil, Pepper, Ranch, SweetOnion, Vinegar
};

正如你在评论中所说, guidlines被描述为:&#34;如果一个字段基于一个枚举并且它不可为空,那么枚举中的0值被认为是null并且你应该在1开始你的枚举。&#34;