No single object in .NET can exceed 2GB: that is an absolute limit. And an array is a single object.
Now, it might not seem that a 3D array of 1000 elements would exceed 2GB - it's only 1,000,000,000 characters, isn't it?
But...
char
is 16 bits (because it's unicode) so that's 2,000,000,000 bytes just in the direct chars, plus the overhead that a 3D array is likely to acquire to support the various dimensions. Basically, you could do it with
byte
values, but
char
just pushes it over the edge.
You could do it as a jagged array:
char[][][] array3d = new char[1000][][];
for (int x = 0; x < 1000; x++)
{
array3d[x] = new char[1000][];
for (int y = 0; y < 1000; y++)
{
array3d[x][y] = new char[1000];
}
}
Because that doesn't create one single huge object.
Will be slow, though!