//冒泡排序 static void BubbleSort(int[] myArray) { for (int i = 0; i < myArray.Length-1; i++) { for (int j = 0; j < myArray.Length-1-i; j++) { if (myArray[j]>myArray[j+1]) { Swap(ref myArray[i],ref myArray[j+1]); } } } } static void Swap(ref int left, ref int right) { int temp; temp = left; left = right; right = temp; }