Description |
A new BitArray is created with the same number of elements and values as the current BitArray.
|
| Notes | You are obliged to cast the resultant Object to a BitArray before assignment to a BitArray variable.
|
|
Microsoft MSDN Links |
System.Collections
System.Collections.BitArray
|
|
|
A simple example |
program Project1;
{$APPTYPE CONSOLE}
uses
System.Collections;
var
Source, Target : System.Collections.BitArray;
i : Integer;
begin
// Create our bit array
Source := System.Collections.BitArray.Create(5);
// Set the values in the array
Source[0] := false; // 0
Source[1] := true; // 1
Source[2] := true; // 1
Source[3] := false; // 0
Source[4] := false; // 0
// Copy to the target array
Target := BitArray(Source.Clone);
// Display all bits in the source and target arrays
for i := 0 to Source.Count-1 do
if Source[i]
then Console.WriteLine('Source [{0}] = 1', i.ToString)
else Console.WriteLine('Source [{0}] = 0', i.ToString);
Console.WriteLine;
for i := 0 to Target.Count-1 do
if Target[i]
then Console.WriteLine('Target [{0}] = 1', i.ToString)
else Console.WriteLine('Target [{0}] = 0', i.ToString);
Console.ReadLine;
end.
| Show full unit code | Source [0] = 0
Source [1] = 1
Source [2] = 1
Source [3] = 0
Source [4] = 0
Target [0] = 0
Target [1] = 1
Target [2] = 1
Target [3] = 0
Target [4] = 0
|
|
|
|