I've got a list (randomRotationVoidList)
that needs to be filled with four different numbers (90, 180, 270, 360)
in a random order, e. g. [270, 180, 180, 90, ...]
. All I've found so far will generate a list with random numbers between a certain range.
Thanks in advance!
Sample for 200 numbers
Random _rnd = new Random();
int[] input = { 90, 180, 270, 360 }; // dictionary of available numbers
List<int> result = Enumerable.Range(0, 200).Select(x => input[_rnd.Next(0, input.Length)]).ToList();
Another approach if the number pattern is fixed to x * 90
Random _rnd = new Random();
List<int> result = Enumerable.Range(0, 200).Select(x => 90 * _rnd.Next(1, 5)).ToList();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With