Reputation: 111
I have an array of ints, that It should like the following:
7 3 2 4 5 6 1 9 10 8 Values
[1 2 3 4 5 6 7 8 9 10] Order In Array
This values should change its order, and every value, it's a random option, for example:
If it chooses that the first value is 6, it chooses the color blue, then, it goes to the second value, if the value is 4, it chooses green.
Every number is equal to a color.
I've been thinking that I can use an if conditional, but I dont know if there's a property to check the value, because if I do a if conditional for each option, it could take like 100+ lines of code!. Do you have any idea of how can I improve it?.
Upvotes: 1
Views: 138
Reputation: 1206
You can do this almost in one line :
var rnd = new Random();
var orderedNumbers = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
var randomizedNumbers = orderedNumbers.OrderBy(c => rnd.Next()).ToArray();
Upvotes: 1