C# BitArray Get

Description

BitArray Get gets the value of the bit at a specific position in the BitArray.

Syntax

BitArray.Get has the following syntax.


public bool Get(
  int index
)

Parameters

BitArray.Get has the following parameters.

  • index - The zero-based index of the value to get.

Returns

BitArray.Get method returns The value of the bit at position index.

Example

The following code example shows how to set and get specific elements in a BitArray.


//from   w ww  . j a v a  2 s  . co  m
using System;
using System.Collections;
public class SamplesBitArray  {

   public static void Main()  {
      BitArray myBA = new BitArray( 5 );
      myBA.SetAll( true );

      Console.WriteLine(myBA.Get( myBA.Count - 2 ) );
      Console.WriteLine(myBA.Get( myBA.Count - 1 ) );
   }

}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections »




ArrayList
BitArray
Comparer
Hashtable
Queue
SortedList
Stack