|
|
A simple example |
program Project1;
{$APPTYPE CONSOLE}
uses
System.Collections;
var
Bits : System.Collections.BitArray;
i : Integer;
begin
// Create our bit array
Bits := System.Collections.BitArray.Create(5);
// Set the values in both arrays
Bits[0] := false; // 0
Bits[1] := true; // 1
Bits[2] := true; // 1
Bits[3] := false; // 0
Bits[4] := false; // 0
// Display all bits in the BitArray
for i := 0 to Bits.Count-1 do
if Bits.Get(i)
then Console.WriteLine('Bits [{0}] = 1', i.ToString)
else Console.WriteLine('Bits [{0}] = 0', i.ToString);
Console.ReadLine;
end.
| Show full unit code | Bits [0] = 0
Bits [1] = 1
Bits [2] = 1
Bits [3] = 0
Bits [4] = 0
|
|
|
|