C# Array Copy(Array, Array, Int64)
Description
Array Copy(Array, Array, Int64)
copies a range of elements
from an Array starting at the first element and pastes them into another Array
starting at the first element. The length is specified as a 64-bit integer.
Syntax
Array.Copy(Array, Array, Int64)
has the following syntax.
public static void Copy(
Array sourceArray,/*from w w w .j a v a 2 s . c om*/
Array destinationArray,
long length
)
Parameters
Array.Copy(Array, Array, Int64)
has the following 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.
Returns
Array.Copy(Array, Array, Int64)
method returns
Example
/* ww w .jav a2 s. c om*/
using System;
public class SamplesArray {
public static void Main() {
Array myIntArray=Array.CreateInstance( typeof(System.Int32), 5 );
for ( int i = myIntArray.GetLowerBound(0); i <= myIntArray.GetUpperBound(0); i++ )
myIntArray.SetValue( i+1, i );
Array myObjArray = Array.CreateInstance( typeof(System.Object), 5 );
for ( int i = myObjArray.GetLowerBound(0); i <= myObjArray.GetUpperBound(0); i++ )
myObjArray.SetValue( i+26, i );
Array.Copy( myIntArray, myObjArray, 2 );
}
}
The code above generates the following result.