方法:
static void Main(string[] args) { string a = "";string b=""; int[] _array = new int[6] { 1, 2, 3, 4, 5, 6 }; for (int i = 0; i < _array.Length; i++) { if (i == 0) { a = "" + _array[i]; } else { a = a+"," + _array[i]; } } Console.WriteLine(a); //RecursiveReverse(_array, 0, _array.Length - 1); RecursiveReverse(_array, 1, 3); for (int i = 0; i < _array.Length; i++) { if (i == 0) { b= "" + _array[i]; } else { b =b+ "," + _array[i]; } } Console.WriteLine(b); Console.ReadLine(); } private static void RecursiveReverse(int[] _array, int left, int right) { if (left >= right) return; //转换方式一 // int temp = list[left]; // list[left] = list[right]; // list[right] = temp; //转换方式二 _array[left] ^= _array[right]; _array[right] ^= _array[left]; _array[left] ^= _array[right]; RecursiveReverse(_array, ++left, --right); }