Copy StringDictionary to Array at the specified index in CSharp
Description
The following code shows how to copy StringDictionary to Array at the specified index.
Example
using System;/* w w w. j ava 2 s. com*/
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(myArr[i].Key + "" + myArr[i].Value );
}
}
}
The code above generates the following result.