抛出异常
public static void Reverse(int[] array, int begin, int end){ if (array == null){ throw new ArgumentNullException("array", "array不能为空"); } if (begin < 0){ throw new ArgumentOutOfRangeException("begin", "begin不能小于0"); } if (end < begin){ throw new ArgumentOutOfRangeException("end不能小于begin", (Exception)null); } if (end >= array.Length){ throw new ArgumentOutOfRangeException("end", "end超过array最大下标"); } while (end > begin){ int temp = array[begin]; array[begin] = array[end]; array[end] = temp; begin++; end--; } }