我有一个列表(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();
Run Code Online (Sandbox Code Playgroud)
如果数字模式固定为另一种方法 x * 90
Random _rnd = new Random();
List<int> result = Enumerable.Range(0, 200).Select(x => 90 * _rnd.Next(1, 5)).ToList();
Run Code Online (Sandbox Code Playgroud)