The BitArray Collection

The System.Collections.BitArray collection enables storing bit values represented by Boolean values. A True value indicates that a bit is on (1), whereas a False value indicates that a bit is off (0). You can pass to the BitArray arrays of Integer numbers or Boolean values, as demonstrated by the following code:

Dim byteArray() As Byte = New Byte() {1, 2, 3}'Length in zero baseDim ba As New BitArray(byteArray)For Each item As Object In ba    Console.WriteLine(item.ToString)Next

This code produces the output shown in Figure 16.1, which is a human-readable representation of the bits in the collection.

FIGURE 16.1 Human-readable representation of bits in a BitArray collection.

The constructor ...

Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.