Why does Array.Copy support Long Arguments

不想你离开。 提交于 2021-02-18 06:25:30

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/3764725/why-does-array-copy-support-long-arguments

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!