Here is the code (I haven’t yet completed this quixort):
private static void QuickSort(int[] array, int start, int end) { if (start == end) return; int pivot = start; int left = start, right = start + 1; for (int i = start + 1; i <= end; ++i) { if (array[i] <= pivot) { int temp = array[right]; array[right] = array[i]; array[i] = temp; ++left; ++right; } } int temp; QuickSort(array, start, left); QuickSort(array, right, end); } The compiler asserts that the temp variable cannot be declared after the cycle of fors, because it is already declared there. But after all, in the cycle of forms, the scope is completely different? And after this cycle, the variable temp, if it was there, disappears. So why I can not declare the second variable temp, but already seemingly in a different scope?