Sometimes, you wanted to copy part of an array to another array. Use the following method, it can handle all
sorts of copy, and don't need to worry the source array and destination array length.
Array.Copy(Array sourceArray, long sourceIndex, Array destinationArray, long destinationIndex, long length);
// Summary:
// Copies a range of elements from an System.Array starting at the specified
// source index and pastes them to another System.Array starting at the specified
// destination index. The length and the indexes are specified as 64-bit integers.
//
// Parameters:
// destinationIndex:
// A 64-bit integer that represents the index in the destinationArray at which
// storing begins.
//
// sourceIndex:
// A 64-bit integer that represents the index in the sourceArray at which copying
// begins.
//
// length:
// A 64-bit integer that represents the number of elements to copy. The integer
// must be between zero and System.Int32.MaxValue, inclusive.
//
// destinationArray:
// The System.Array that receives the data.
//
// sourceArray:
// The System.Array that contains the data to copy.
//
sorts of copy, and don't need to worry the source array and destination array length.
Array.Copy(Array sourceArray, long sourceIndex, Array destinationArray, long destinationIndex, long length);
// Summary:
// Copies a range of elements from an System.Array starting at the specified
// source index and pastes them to another System.Array starting at the specified
// destination index. The length and the indexes are specified as 64-bit integers.
//
// Parameters:
// destinationIndex:
// A 64-bit integer that represents the index in the destinationArray at which
// storing begins.
//
// sourceIndex:
// A 64-bit integer that represents the index in the sourceArray at which copying
// begins.
//
// length:
// A 64-bit integer that represents the number of elements to copy. The integer
// must be between zero and System.Int32.MaxValue, inclusive.
//
// destinationArray:
// The System.Array that receives the data.
//
// sourceArray:
// The System.Array that contains the data to copy.
//
No comments:
Post a Comment