er, not quite. Stores the same data elements in a very different and a lot more flexible fashion… perhaps you need to brush up on the difference between arrays and list collections?
Probably because an array requires a lot of effort to resize (you could call AddOptions more than once on the same Dropdown), and List already does that work.
If you’re worried about it or prefer to store your data in an array, just create a throw-away List when you make the call:
That only matters for how the options are stored - not what argument types are allowed to be added to the existing options. It would appear that options are held as a list since the options property returns one.
If they were smart - and assuming AddOptions is more or less a wrapper around List.AddRange then they would have just made the argument an IEnumerable and then you could give it both.
You can create an extension method to allow passing the array.
public static class Extensions
{
public static void AddOptions(this Dropdown dropdown, string[] options)
{
dropdown.AddOptions(new List<string>(options));
}
}
It’s not really buying you anything other than a syntax shortcut. You’ll also get some garbage because of creating the list from the array, but if it’s not something you’re using all the time that shouldn’t be much of a problem.