Is the size of an array constrained by the upper limit of int (2147483647)?

后端 未结 6 1292
梦谈多话
梦谈多话 2020-12-06 19:06

I\'m doing some Project Euler exercises and I\'ve run into a scenario where I have want arrays which are larger than 2,147,483,647 (the upper limit of

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-06 19:50

    I'm very much a newbie with C# (i.e. learning it this week), so I'm not sure of the exact details of how ArrayList is implemented. However, I would guess that as you haven't defined a type for the ArrayList example, then the array would be allocated as an array of object references. This might well mean that you are actually allocating 4-8Gb of memory depending on the architecture.

提交回复
热议问题