I would like to do something like this:
comboBox6.Items.AddRange(new IEnumerable<int> { Enumerable.Range(1,8).ToArray() } );
(add numbers 1 to 8 to ComboBox Items using an IEnumerable object), but i can't figure out how.
Thanks.
I would like to do something like this:
comboBox6.Items.AddRange(new IEnumerable<int> { Enumerable.Range(1,8).ToArray() } );
(add numbers 1 to 8 to ComboBox Items using an IEnumerable object), but i can't figure out how.
Thanks.
I found this:
comboBox6.Items.AddRange(Enumerable.Range(1, 8).Cast<object>().ToArray());
Is it possible without casting?
And why is this working
comboBox6.Items.AddRange(new string[] { "Yes", "No" });
and this one
comboBox6.Items.AddRange(new int[] {1,2,3,4,5,6,7,8});
is not?
Dont want to sound too smart here but it's the same as the output from the MessageBox.Show(string) you must have a string output otherwise you'll get an error ...
For your other part I would just go and convert each element to a string
comboBox6.Items.AddRange(new int[]{1,2,3,4,5}.Select(x=>x.ToString()).ToArray());
Afters you could just convert these string to int's depending what you want to do with it...
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.