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)];