I have program where I have to work with extremly big arrays. I need to use two-dimensional arrays.
I've used classical bool[,], but it throwed System.OutOfMemoryException when I tried to declare it when the index was just too big. (Used bool[,] foo = new bool[width + bar, height]). Both numbers width and bar were extremly big, so I suppose, it just exceeded the index.
How can I change index type to Int64 (long)? I know I can use Dictionary<ulong, bool>, but it would force me to rewrite almost all code in my app and I find array much more comfortable to work then with Dictionary, especially when I already have LINQ methods that I need and I don't know, if it would work with two dimensional dictionary.
Thanks, Peter
EDIT 1:
Here's the code (note: I've just tested it with sizeX = 2000000000, it threw the exception):
bool[,] pole = new bool[sizeX, maxY];
The problem is, I have many objects with their X, y-length and x-length (Y is always 0). I have an array where on each position, there either is or isn't object tile.
So I just get coord X, width & height and position tiles into array.
The point is, X can be negative, so when I need to position for example 10 objects, I get lowest X (and save it for example largestNegativeX = -999) and before positioning objects into array, I add to every object's X object.X += -largestNegativeX. Then I figure out array width (for example 2000000000) and try to declare the array. And it's where the exception is thrown.