Не используйте рекурсию для этого.Вместо этого используйте итеративное решение
Обновление: Если вы посмотрите на документ для StackOverflowExectpion , оно говорит
Исключение, которое выдается, когдастек выполнения переполняется, потому что он содержит слишком много вложенных вызовов методов.
При написании этого вида каждый элемент посещается с помощью рекурсивного вызова метода.например, первый элемент вызывает sort для второго элемента, который вызывает sort для третьего элемента и так далее.Это означает, что глубина рекурсии равна количеству членов (я могу быть отключен на +/- 1).
Это означает, что если у вас будет достаточно элементов, вы получите StackOverflow.
Я скопировал ваш код и запустил его, а ниже приведен усеченный стек вызовов, который показывает, что сортировка вызывается для каждой позиции рекурсивно и что она умирает при наличии более 8,314 элементов.
MyApp.exe!MyApp.SelectionSort.Sort(Integer arrLen = 10000, Integer pos = 8314, Integer minval = 1) Line 67 + 0xb bytes Basic
MyApp.exe!MyApp.SelectionSort.Sort(Integer arrLen = 10000, Integer pos = 8314, Integer minval = 1) Line 75 + 0x14 bytes Basic
MyApp.exe!MyApp.SelectionSort.Sort(Integer arrLen = 10000, Integer pos = 8313, Integer minval = 1) Line 75 + 0x14 bytes Basic
MyApp.exe!MyApp.SelectionSort.Sort(Integer arrLen = 10000, Integer pos = 8312, Integer minval = 1) Line 75 + 0x14 bytes Basic
MyApp.exe!MyApp.SelectionSort.Sort(Integer arrLen = 10000, Integer pos = 8311, Integer minval = 1) Line 75 + 0x14 bytes Basic
MyApp.exe!MyApp.SelectionSort.Sort(Integer arrLen = 10000, Integer pos = 8310, Integer minval = 1) Line 75 + 0x14 bytes Basic
MyApp.exe!MyApp.SelectionSort.Sort(Integer arrLen = 10000, Integer pos = 8309, Integer minval = 1) Line 75 + 0x14 bytes Basic
MyApp.exe!MyApp.SelectionSort.Sort(Integer arrLen = 10000, Integer pos = 8308, Integer minval = 1) Line 75 + 0x14 bytes Basic
MyApp.exe!MyApp.SelectionSort.Sort(Integer arrLen = 10000, Integer pos = 8307, Integer minval = 1) Line 75 + 0x14 bytes Basic
MyApp.exe!MyApp.SelectionSort.Sort(Integer arrLen = 10000, Integer pos = 8306, Integer minval = 1) Line 75 + 0x14 bytes Basic
MyApp.exe!MyApp.SelectionSort.Sort(Integer arrLen = 10000, Integer pos = 8305, Integer minval = 1) Line 75 + 0x14 bytes Basic
MyApp.exe!MyApp.SelectionSort.Sort(Integer arrLen = 10000, Integer pos = 8304, Integer minval = 1) Line 75 + 0x14 bytes Basic
MyApp.exe!MyApp.SelectionSort.Sort(Integer arrLen = 10000, Integer pos = 8303, Integer minval = 1) Line 75 + 0x14 bytes Basic
MyApp.exe!MyApp.SelectionSort.Sort(Integer arrLen = 10000, Integer pos = 8302, Integer minval = 1) Line 75 + 0x14 bytes Basic