Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要随机化固定数字,例如 1、3、5、7、10。我的输出将只有 1,3,5,7 或 10。请帮助我!谢谢!有没有办法随机化固定数字或用户输入的数字?
从 0-4 中获取一个随机数,然后从{ 1, 3, 5, 7, 10 }.
{ 1, 3, 5, 7, 10 }
int[] select = new int[] { 1, 3, 5, 7, 10 }; var rand = new Random(); int num = select[rand.Next(5)];