C# HybridDictionary CopyTo

Description

HybridDictionary CopyTo copies the HybridDictionary entries to a one-dimensional Array instance at the specified index.

Syntax

HybridDictionary.CopyTo has the following syntax.


public void CopyTo(
  Array array,
  int index
)

Parameters

HybridDictionary.CopyTo has the following parameters.

  • array - The one-dimensional Array that is the destination of the DictionaryEntry objects copied from HybridDictionary. The Array must have zero-based indexing.
  • index - The zero-based index in array at which copying begins.

Returns

HybridDictionary.CopyTo method returns

Example

The following code example copies the elements of a HybridDictionary to an array.


/*from w ww. j  a v a  2s . c  om*/
using System;
using System.Collections;
using System.Collections.Specialized;

public class SamplesHybridDictionary  {
   public static void Main()  {
      HybridDictionary myCol = new HybridDictionary();
      myCol.Add( "F", "1.49" );
      myCol.Add( "A", "1.29" );
      myCol.Add( "B", "1.49" );
      myCol.Add( "C", "1.29" );

      DictionaryEntry[] myArr = new DictionaryEntry[myCol.Count];
      myCol.CopyTo( myArr, 0 );

      for ( int i = 0; i < myArr.Length; i++ )
         Console.WriteLine( "   {0,-25} {1}", myArr[i].Key, myArr[i].Value );
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections.Specialized »




BitVector32
HybridDictionary
ListDictionary
OrderedDictionary
StringCollection
StringDictionary
StringEnumerator