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

后端 未结 6 1306
梦谈多话
梦谈多话 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:41

    I believe that even within a 64 bit CLR, there's a limit of 2GB (or possibly 1GB - I can't remember exactly) per object. That would prevent you from creating a larger array. The fact that Array.CreateInstance only takes Int32 arguments for sizes is suggestive too.

    On a broader note, I suspect that if you need arrays that large you should really change how you're approaching the problem.

提交回复
热议问题