I need to make an 2d array, but c# won't let me and says that it is too big, any ideas how to make it work?
int[,] arrayName = new int[37153,18366];
I need to make an 2d array, but c# won't let me and says that it is too big, any ideas how to make it work?
int[,] arrayName = new int[37153,18366];
The max theoretical size of an int array is 2147483647 i.e. int[] array = new int[2147483647]
but the probleming you're having here is that the computer runs of out memory.
Read this for explanation and tips on how to solve this: OutOfMemoryException on declaration of Large Array
If you are not using the complete range of the array (which is in your case 2,7GB of RAM), you could use a Dictionary
.
https://msdn.microsoft.com/de-de/library/xfhwa508(v=vs.110).aspx
Alternative: Create a [][] Array. In this case you must initialize each row.
But you can access each cell easy with arrayName[row][col]
.
int[][] arrayName = new int[37153][];
for(int i=0; i<arrayName.Length; i++)
arrayName[i] = new int[18366];