我通过查看指南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
};
代码运行时,选择ToppingOptions
和SauceOptions
,
缺少第一个选项。这是一个错误吗?
a picture to show the result
答案 0 :(得分:1)
首先,在示例中,他们将列表声明为&#39; ToppingOptions&#39;值,仅使用List<ToppingOptions>
而不是List
,如果它仍然不起作用,请尝试更改枚举的第一个值并将其设置为1,并将其他值保持为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;