c# - What is the maximum size of an array while using Array.sort() method? -


in application have array 5000 elements. have sort these elements.but getting error of "array index out of bound exception". can tell me can maximum size array sort?

should use arraylist ??

there no specific limit - constrained memory here, , @ point array exists, isn't limitation of array.sort. example:

int[] arr = new int[500000]; random rand = new random(); (int = 0; < arr.length; i++) arr[i] = rand.next(); array.sort(arr); // works fine 

i suspect might (for example) have icomparable[<t>] implementation throwing error internally? or alternatively, perhaps error has nothing @ do array.sort, , have considered wrong line cause.

the exception's .stacktrace should reveal everything, of course.

and no: shouldn't use arraylist here. or pretty anywhere else.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -