List of random numbers - arc4random

前端 未结 2 1046
春和景丽
春和景丽 2021-01-27 17:52

I want to create an array of numbers from 0-9 and want them to be randomized

Meaning, when a user clicks on a UIButton it creates an NSMutableArray of objects 4,5,8,3,6,

2条回答
  •  一生所求
    2021-01-27 18:20

    You might want to use Random and Linq

    Random random = new Random(0);
    var myRandom = Enumerable.Repeat(0, n).Select(i => random.Next(0, 9));
    

    where n is the amount of digits you want

    Hope that helps

提交回复
热议问题