I want to declare array 2^32 size on 32 bit OS for integer hash table.tell me what to do? It is giving me Out of memory exception.
You simply can't do this. In a 32-bit CLR, all objects must be less than 2GB in size.
Even in a 64-bit CLR, you have to specify a special flag to enable larger arrays (<gcAllowVeryLargeObjects>
) - and if your array is an array of integers, you're actually asking for 16GB. It seems unlikely that you'd have that much physical memory on a 32-bit OS.
You can work around the limit to some extent by making one "logical" array composed of multiple smaller arrays, but I rarely view that as a good idea. Basically, you should either redesign or use an OS that's more suitable for your requirements. I suspect that a redesign is likely to be the best approach.
See more on this question at Stackoverflow