C# BitArray CopyTo

Description

BitArray CopyTo copies the entire BitArray to a compatible one-dimensional Array, starting at the specified index of the target array.

Syntax

BitArray.CopyTo has the following syntax.


public void CopyTo(
  Array array,
  int index
)

Parameters

BitArray.CopyTo has the following parameters.

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

Returns

BitArray.CopyTo method returns

Example

The following code example shows how to copy a BitArray into a one-dimensional Array.


//from   w ww  .  j a v  a  2s.  c o  m
using System;
using System.Collections;
public class SamplesBitArray  {
   public static void Main()  {
      BitArray myBA = new BitArray( 4 );
      myBA[0] = myBA[1] = myBA[2] = myBA[3] = true;

      bool[] myBoolArray = new bool[8];
      myBoolArray[0] = false;
      myBoolArray[1] = false;

      myBA.CopyTo( myBoolArray, 3 );
   }

   public static void PrintValues( IEnumerable myArr )  {
      foreach ( Object obj in myArr ) {
         Console.WriteLine(obj );
      }
   }
}




















Home »
  C# Tutorial »
    System.Collections »




ArrayList
BitArray
Comparer
Hashtable
Queue
SortedList
Stack