byte[] buffer2 = new byte[4294743227]; // string with System.OverflowException
The number 4294743227 is uint.
Why do i get exception?
byte[] buffer2 = new byte[4294743227]; // string with System.OverflowException
The number 4294743227 is uint.
Why do i get exception?
According to this question, the maximum size of an array is System.Int32.MaxValue
, which is 2,147,483,647.
See also the documentation on System.Array
:
By default, the maximum size of an Array is 2 gigabytes (GB). In a 64-bit environment, you can avoid the size restriction by setting the enabled attribute of the gcAllowVeryLargeObjects configuration element to true in the run-time environment. However, the array will still be limited to a total of 4 billion elements, and to a maximum index of 0X7FEFFFFF in any given dimension (0X7FFFFFC7 for byte arrays and arrays of single-byte structures).