Gets the value of the bit at a specific position in the BitArray. : BitArray « Collections Data Structure « C# / C Sharp






Gets the value of the bit at a specific position in the BitArray.

 

using System;
using System.Collections;
public class SamplesBitArray  {
   public static void Main()  {
      BitArray myBA = new BitArray( 5 );
      myBA.SetAll( true );

      PrintIndexAndValues( myBA );
      myBA.Set( myBA.Count - 1, false );
      PrintIndexAndValues( myBA );

      Console.WriteLine( myBA.Get( myBA.Count - 2 ) );
      Console.WriteLine( myBA.Get( myBA.Count - 1 ) );
   }
   public static void PrintIndexAndValues( IEnumerable myCol )  {
      int i = 0;
      foreach ( Object obj in myCol ) {
         Console.WriteLine( "    [{0}]:    {1}", i++, obj );
      }
   }
}

   
  








Related examples in the same category

1.Demonstrate BitArrayDemonstrate BitArray
2.Use BitArray collection as Flag
3.illustrates the use of a BitArrayillustrates the use of a BitArray
4.illustrates the use of BitArray methodsillustrates the use of BitArray methods
5.BitArray Class manages a compact array of bit values
6.Displays the properties and values of the BitArrays
7.BitArray.CopyTo copies the entire BitArray to a compatible one-dimensional Array
8.Inverts all the bit values in the current BitArray
9.Performs the bitwise OR operation
10.Performing OR between BitArray instances of different sizes returns an exception
11.Performs bitwise exclusive OR operation