我有一个列表(randomRotationVoidList)
,需要以随机顺序(90, 180, 270, 360)
填充四个不同的数字,例如。[270, 180, 180, 90, ...]
.到目前为止,我发现的所有内容都将生成一个列表,其中包含一定范围内的随机数。
提前感谢!
200 个数字的示例
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();
如果数字模式固定为x * 90
,则采用另一种方法
Random _rnd = new Random();
List<int> result = Enumerable.Range(0, 200).Select(x => 90 * _rnd.Next(1, 5)).ToList();