Gets the value of the bit at a specific position in the BitArray. : BitArray « Data Structure « VB.Net






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

 

Imports System
Imports System.Collections
Imports Microsoft.VisualBasic

Public Class SamplesBitArray    

    Public Shared Sub Main()
        Dim myBA As New BitArray(5)
        PrintIndexAndValues(myBA)

        ' Sets all the elements to true.
        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))
    End Sub 'Main

    Public Shared Sub PrintIndexAndValues(myCol As IEnumerable)
        Dim obj As Object
        For Each obj In  myCol
            Console.WriteLine(obj)
        Next obj
    End Sub

End Class

   
  








Related examples in the same category

1.BitArray Class manages a compact array of bit values, which are represented as Booleans
2.Initialize BitArray with False values
3.Initialize BitArray from Byte array
4.Initialize BitArray from Boolean value array
5.Initialize BitArray from Integer array
6.Performs the bitwise AND operation for BitArray
7.Copies BitArray to a compatible one-dimensional Array
8.Inverts all the bit values in the current BitArray
9.BitArray.Or Performs the bitwise OR operation
10.BitArray.Xor performs the bitwise exclusive OR operation