Missing first option when using List <T> in FormFlow, BotFramework
I am writing a demo FormFlow
by looking at the guidelines https://docs.botframework.com/en-us/csharp/builder/sdkreference/forms.html , it works well. In the demo "Simple Sandwich Bot"
, Sandwich.cs
enumerations are listed:
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
};
when the code is running, and for the selection ToppingOptions
and SauceOptions
, the first option is missing. This is mistake?
image to show the result
source to share
First of all, in the example they are declaring the list as the value of "ToppingOptions", use List<ToppingOptions>
instead List
, only if it doesn't work, try changing the first value of the enums and set it = 1 and keep the rest like
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
};
As you said in a comment, the directives describe: "If a field is enumerated based and is not NULL, then the value 0 in the enumeration is considered null and you must start enumerating at 1."
source to share