C# StringDictionary CopyTo
Description
StringDictionary CopyTo
copies the string dictionary
values to a one-dimensional Array instance at the specified index.
Syntax
StringDictionary.CopyTo
has the following syntax.
public virtual void CopyTo(
Array array,
int index
)
Parameters
StringDictionary.CopyTo
has the following parameters.
array
- The one-dimensional Array that is the destination of the values copied from the StringDictionary.index
- The index in the array where copying begins.
Returns
StringDictionary.CopyTo
method returns
Example
The following code example shows how a StringDictionary can be copied to an array.
/*from w ww . j a va2s.c o m*/
using System;
using System.Collections;
using System.Collections.Specialized;
public class SamplesStringDictionary {
public static void Main() {
StringDictionary myCol = new StringDictionary();
myCol.Add( "red", "rojo" );
myCol.Add( "green", "verde" );
myCol.Add( "blue", "azul" );
DictionaryEntry[] myArr = { new DictionaryEntry(), new DictionaryEntry(), new DictionaryEntry() };
myCol.CopyTo( myArr, 0 );
for ( int i = 0; i < myArr.Length; i++ )
Console.WriteLine( "{0}\t{1}", myArr[i].Key, myArr[i].Value );
}
}
The code above generates the following result.