在 FormFlow、BotFramework 中使用 List<T> 时缺少第一个选项
Missing the first option when use List<T> in FormFlow,BotFramework
我通过查看指南 https://docs.botframework.com/en-us/csharp/builder/sdkreference/forms.html 编写了一个 FormFlow
演示,它运行良好。
在演示 "Simple Sandwich Bot"
, Sandwich.cs
中,有 enum:
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
,
第一个选项是 missing.Is 这是一个错误?
a picture to show the result
首先,在示例中,他们将列表声明为 'ToppingOptions' 值,仅使用 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
};
正如您在评论中所说,指南描述如下:"If a field is based on an enum and it is not nullable, then the 0 value in the enum is considered to be null and you should start your enumeration at 1."
我通过查看指南 https://docs.botframework.com/en-us/csharp/builder/sdkreference/forms.html 编写了一个 FormFlow
演示,它运行良好。
在演示 "Simple Sandwich Bot"
, Sandwich.cs
中,有 enum:
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
,
第一个选项是 missing.Is 这是一个错误?
a picture to show the result
首先,在示例中,他们将列表声明为 'ToppingOptions' 值,仅使用 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
};
正如您在评论中所说,指南描述如下:"If a field is based on an enum and it is not nullable, then the 0 value in the enum is considered to be null and you should start your enumeration at 1."