This documentation is archived and is not being maintained.

NameValueCollection.CopyTo Method

Copies the entire NameValueCollection to a compatible one-dimensional Array, starting at the specified index of the target array.

[Visual Basic]
Public Sub CopyTo( _
   ByVal dest As Array, _
   ByVal index As Integer _
public void CopyTo(
 Array dest,
 int index
public: void CopyTo(
 Array* dest,
 int index
public function CopyTo(
   dest : Array,
 index : int


The one-dimensional Array that is the destination of the elements copied from NameValueCollection. The Array must have zero-based indexing.
The zero-based index in dest at which copying begins.


Exception Type Condition
ArgumentNullException dest is a null reference (Nothing in Visual Basic).
ArgumentOutOfRangeException index is less than zero.
ArgumentException dest is multidimensional.


index is equal to or greater than the length of dest.


The number of elements in the source NameValueCollection is greater than the available space from index to the end of the destination dest.

InvalidCastException The type of the source NameValueCollection cannot be cast automatically to the type of the destination dest.


The specified array must be of a compatible type.

This method uses Array.Copy to copy the elements.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

NameValueCollection Class | NameValueCollection Members | System.Collections.Specialized Namespace