1,从第一个元素开始复制 Array 中的一系列元素,将它们粘贴到另一 Array 中(从第一个元素开始)。长度指定为 32 位整数。

Visual Basic(声明)
PublicSharedSubCopy( _sourceArrayAsArray
, _destinationArrayAsArray
, _lengthAsInteger_
)
Visual Basic(用法)
DimsourceArrayAsArrayDimdestinationArrayAsArrayDimlengthAsIntegerArray
.Copy
(sourceArray
, destinationArray
, _length
)
publicstaticvoidCopy
(ArraysourceArray
,ArraydestinationArray
,intlength

)

参数

sourceArray
类型:System. Array

Array ,它包含要复制的数据。

destinationArray
类型:System. Array

Array ,它接收数据。

length
类型:System. Int32

一个 32 位整数,它表示要复制的元素数目

2,从第一个元素开始复制 Array中的一系列元素,将它们粘贴到另一 Array中(从第一个元素开始)。长度指定为 64 位整数。publicstaticvoidCopy
(ArraysourceArray
,ArraydestinationArray
,longlength

)

参数

sourceArray
类型:System. Array

Array ,它包含要复制的数据。

destinationArray
类型:System. . Array

Array ,它接收数据。

length
类型:System. Int64

一个 64 位整数,它表示要复制的元素数目。该整数必须介于零和 Int32. MaxValue 之间(包括零和 Int32. MaxValue )。

3,从指定的源索引开始,复制 Array中的一系列元素,将它们粘贴到另一 Array中(从指定的目标索引开始)。长度和索引指定为 32 位整数。publicstaticvoidCopy
(ArraysourceArray
,intsourceIndex
,ArraydestinationArray
,intdestinationIndex
,intlength

)

参数

sourceArray
类型:System. Array

Array ,它包含要复制的数据。

sourceIndex
类型:System. Int32

一个 32 位整数,它表示 sourceArray 中复制开始处的索引。

destinationArray
类型:System . Array

Array ,它接收数据。

destinationIndex
类型:System. Int32

一个 32 位整数,它表示 destinationArray 中存储开始处的索引。

length
类型:System. . :: . Int32

一个 32 位整数,它表示要复制的元素数目。

4,从指定的源索引开始,复制 Array中的一系列元素,将它们粘贴到另一 Array中(从指定的目标索引开始)。长度和索引指定为 64 位整数。publicstaticvoidCopy
(ArraysourceArray
,longsourceIndex
,ArraydestinationArray
,longdestinationIndex
,longlength

)

参数

sourceArray
类型:System. Array

Array ,它包含要复制的数据。

sourceIndex
类型:System. Int64

一个 64 位整数,它表示 sourceArray 中复制开始处的索引。

destinationArray
类型:System. Array

Array ,它接收数据。

destinationIndex
类型:System. Int64

一个 64 位整数,它表示 destinationArray 中存储开始处的索引。

length
类型:System. Int64

一个 64 位整数,它表示要复制的元素数目。该整数必须介于零和 Int32. . MaxValue 之间(包括零和 Int32. MaxValue )。

5,下面的代码示例说明如何从一个 Object 类型的 Array 复制到 integer 类型的另一个 Array 。

usingSystem;publicclassSamplesArray  {

publicstaticvoidMain()  {

// Creates and initializes a new Array of type Int32.
Array myIntArray=Array.CreateInstance( typeof
(System.Int32), 5 );for( int i = myIntArray.GetLowerBound(0); i <= myIntArray.GetUpperBound(0); i++ )myIntArray.SetValue( i+1, i );

// Creates and initializes a new Array of type Object.
Array myObjArray = Array.CreateInstance( typeof
(System.Object), 5 );for( int i = myObjArray.GetLowerBound(0); i <= myObjArray.GetUpperBound(0); i++ )myObjArray.SetValue( i+26, i );

// Displays the initial values of both arrays.
Console.WriteLine( "Int32 array:");PrintValues( myIntArray );Console.WriteLine( "Object array:");PrintValues( myObjArray );

// Copies the first element from the Int32 array to the Object array.
Array.Copy( myIntArray, myIntArray.GetLowerBound(0), myObjArray, myObjArray.GetLowerBound(0), 1 );

// Copies the last two elements from the Object array to the Int32 array.
Array.Copy( myObjArray, myObjArray.GetUpperBound(0) - 1, myIntArray, myIntArray.GetUpperBound(0) - 1, 2 );

// Displays the values of the modified arrays.
Console.WriteLine( "Int32 array - Last two elements should now be the same as Object array:");PrintValues( myIntArray );Console.WriteLine( "Object array - First element should now be the same as Int32 array:");PrintValues( myObjArray );}

publicstaticvoidPrintValues( Array myArr )  {System.Collections.IEnumerator myEnumerator = myArr.GetEnumerator();int i = 0;int cols = myArr.GetLength( myArr.Rank - 1 );while( myEnumerator.MoveNext() )  {if( i < cols )  {i++;} else{Console.WriteLine();i = 1;}Console.Write( "/t{0}"
, myEnumerator.Current );}Console.WriteLine();}
}/*
This code produces the following output.

Int32 array:1    2    3    4    5
Object array:26    27    28    29    30
Int32 array - Last two elements should now be the same as Object array:1    2    3    29    30
Object array - First element should now be the same as Int32 array:1    27    28    29    30
*/

Array.Copy 方法 总结相关推荐

  1. C#把某个数组的一部分复制到另一个数组中的两种方法:Buffer.BlockCopy和Array.Copy...

    static void Main(string[] args){int[] src = new[] { 1, 2, 3, 4, 5, 6 };const int destLen = 4;//目标数组大 ...

  2. Worksheet.Copy 方法 (Excel)

    将工作表复制到当前工作簿或新工作簿中的另一个位置. 语法 表达式.复制 (_之前._之后) 表达式 一个代表 Worksheet 对象的 变量. 参数 名称 必需/可选 数据类型 说明 Before ...

  3. C#中数组合并(Array.Copy的用法)

    首先应该理解数组在<数据结构>中的概念,数组是一个线性表,在定义的时候由内存分配一个指定大小的内存空间,所以相较于链表(C#中又叫集合)缺点就是不利于扩展. 针对合并两个数组的方法就是创建 ...

  4. Python中列表的copy方法

    首先感谢,资料由网上的查询共享并保存下来的,该资料完全是用来学习,希望大家有用. 1.在列表中存在一个名为copy的方法,就像字面意思一样copy方法是用于复制列表元素的,示例如下: 1 names ...

  5. Java IOUtils.copy方法代码示例(亲测)

    本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...

  6. JS Array filter()方法

    JS Array filter()方法 js的数据对象有一个fileter()方法,运行传入一个方法,并对数组中的每个元素进行过滤. var arr = [1,2,3,4,5,6]; function ...

  7. ruby array_Ruby中带有示例的Array.select方法

    ruby array Array.select方法 (Array.select Method) In the last articles, we have seen how to iterate ov ...

  8. Python3 字典 copy()方法

    描述 Python 字典 copy() 函数返回一个字典的浅复制. 语法 copy()方法语法: dict.copy() 参数 • NA. 返回值 返回一个字典的浅复制. 实例 以下实例展示了 cop ...

  9. 取某个单元格的值_vba中如何进行单元格复制,Copy方法使用介绍,一定要学

    NO.1 在Excel操作过程当中,除了给表格输入内容就数单元格复制最常用了,通常快捷方法有Ctrl+c,Ctrl+v. 不用说,这种方法对于操作十分方便,那么如何利用代码来实现复制功能呢! 因为在编 ...

最新文章

  1. com.android.providers.telephony.MmsSmsDatabaseHelper
  2. Windows/Linux高精度计时器(C++)
  3. 行为模式之Template Method模式
  4. golang 中的sort 包
  5. 暴君第一季/全集Tyrant迅雷下载
  6. Discuz!NT 模板机制分析(转)
  7. win7系统电脑运行速度的提升方法
  8. NFS双机热备探究实验
  9. LED显示驱动(三):显示驱动底层学习小结
  10. SEO行业应该如何给客户报价
  11. linux谷歌浏览器无法登陆,使用chrome/chrominum浏览器无法正常登陆deepin论坛的解决...
  12. 二八定律 80/20法则 帕累托法则、帕累托定律、马特莱定律、最省力法则或不平衡原则
  13. linux df -h显示空间信息不正确
  14. dtmf拨号原理matlab,matlab综合实验dtmf拨号器设计.doc
  15. 垃圾小白羊的leetcode刷题记录7
  16. 安卓开发上传相册图片成功上传拍照图片失败解决办法
  17. 关于将微信小程序部署到云服务器上的具体步骤
  18. 希尔伯特变换(Hilbert Transform)的性质
  19. html在线弹幕,HTML5 弹幕
  20. Nginx 配置示例

热门文章

  1. deepin启动盘无法引导安装_深度启动盘制作工具(Deepin Boot Maker)怎么安装kubuntu?Deepin Boot Maker图文教程...
  2. hdu4993(水题)
  3. POJ 1201 差分约束(集合最小元素个数)
  4. hdu4279 找规律+小想法
  5. 【错误记录】p7zip 交叉编译 Android 版本 NDK 报错 ( Application.mk | APP_ABI := armeabi-v7a arm64-v8a x86 x86_64 )
  6. 【Android 进程保活】提升进程优先级 ( 使用前台 Service 提高应用进程优先级 | 效果展示 | 源码资源 )
  7. 【Android RTMP】音频数据采集编码 ( FAAC 头文件与静态库拷贝到 AS | CMakeList.txt 配置 FAAC | AudioRecord 音频采样 PCM 格式 )
  8. Beta阶段——第4篇 Scrum 冲刺博客
  9. linux ssh认证(公钥机)配置
  10. Java并发程序设计(四)JDK并发包之同步控制