要是让button的name用数字随机生成,应该是1-16,那么如何使每个数字出现四次,如果让出现的数字用数组存起来,之后的代码该怎么写????
4条回答 默认 最新
threenewbee 2015-01-16 06:19关注using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { int[] result = Enumerable.Range(0, 16).SelectMany(x => Enumerable.Repeat(x, 4)).OrderBy(_ => Guid.NewGuid()).ToArray(); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { Console.Write(result[i * 8 + j] + "\t"); } Console.WriteLine(); } } } }本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报