C#洗牌using System; using System.Diagnostics; using System.Collections; namespace Dachie { class Program { static void Main(string[] args) { //初始化牌局 int[] array = new int[54]; for (int i = 0; i < array.Length; i++) { array[i] = i+1; } //洗牌 Permute<int>(array); } static void Permute<T>(T[] array) { Random random = new Random(); for (int i = 1; i < array.Length; i++) { Swap<T>(array, i, random.Next(0, i)); } } static void Swap<T>(T[] array, int indexA, int indexB) { T temp = array[indexA]; array[indexA] = array[indexB]; array[indexB] = temp; } } }