10Gb in one object (24 bytes (size of nullable decimal) * 20000 * 20000) exceeds the default size of a single object in .NET (i.e., the CLR) - see this MSDN documentation "gcAllowVeryLargeObjects Element" on how to exceed that by changing a configuration variable. That article also lists other limits on arrays that you may be interested in, e.g., you can only have 2^32 elements in an array - in case 400M elements isn't enough and you're thinking of taking it to the next level.
A better solution would be a "jagged" array, notated [][]
in C# - each row will be a separate object (a 1-D array []
) and thus you won't hit any of these limits.
You might want to consider other options. E.g., perhaps your array is sparse? Perhaps it is a matrix with usable attributes e.g., upper triangular? Perhaps you can rethink what you're doing so you don't need a 10Gb array of anything - instead preferring another data structure or even better, if that amount of data really needs to be processed, an external algorithm that stores the data on disk and accesses it in a predictable (e.g., sequential, or multiple-sequential) way?
And finally, I question why you need a giant array of nullable decimal: sounds like you really have a sparse array and should be looking at solutions for sparse arrays (plenty on StackOverflow and Google about those).