2
Contributors
2
Replies
27
Views
3 Years
Discussion Span
Last Post by castajiz_2
0

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?

Edited by tanatos.daniel

1

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...

Edited by castajiz_2: none

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.