I have a method that returns a List<string> and I'm trying to pass that to the AddRange(Object[]) method of a ComboBox.
How can I convert my List<string> to Object[]?
I suppose I could do a foreach but I'd rather use the AddRange(Object[]) as it's faster (and produces less code).
EDIT
The following works fine:
var list = new List<string>();
object[] array = list.ToArray<object>();
comboBox.AddRange(array);
However, on another note, any reason why I would want to perform the above instead of:
var list = new list<string>();
comboBox.AddRange(list.ToArray<object>());