tags:

views:

72

answers:

1

From the MSDN:

Parameters sourceArray

The Array that contains the data to copy. destinationArray

The Array that receives the data. length

A 64-bit integer that represents the number of elements to copy. The integer must be between zero and Int32.MaxValue, inclusive

Given that the permitted range of values is 0 to Int32.MaxValue, what is the motivation for adding this signature? It did not exist in .Net 1.0 and was only added in .Net 1.1. My only guess is to prepare for 64-bit Framework implementations.

+2  A: 

Curiously an array also has overloads for GetItem that take either an Int32 and an Int64. But in practice you cannot have a single object larger than 2 gigabytes in the current implementation of the .NET framework so you can't actually create an array that allows such large indexes.

I guess if this restriction were lifted later then it would mean that they don't need to change the interface.

Mark Byers
That makes me wonder if one could define an array with a lower bound > int.MaxValue...
dtb
@dtb: Not using `CreateInstance` because the length parameter is an int. If you try to do something like `Array my1DIntArray = Array.CreateInstance(typeof(Int64), new int[] { 3 }, new int[] { Int32.MaxValue - 1 });` , you get an `ArgumentOutOfRangeException` with the message, `Array my1DIntArray = Array.CreateInstance(typeof(Int64), new int[] { 3 }, new int[] { Int32.MaxValue - 1 });`
Brian