Home  |  Delphi .net Home  |  System.Collections.BitArray  |  Not Method
  
Not  
Method  
Creates a copy of the current BitArray with all values inverted
BitArray Class
System.Collections NameSpace
CF1.  Procedure Not ( Source : BitArray ) ;
CF : Methods with this mark are Compact Framework Compatible
Description
A new BitArray is created that has all of the Source elements, but inverted. 1 values become 0, 0 values become 1.
Notes
IMPORTANT : you must prefix the method name Not with an & to avoid a compiler error, where the method name is confused with the native Delphi operator.
Microsoft MSDN Links
System.Collections
System.Collections.BitArray
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

uses
  System.Collections;

var
  Source, Target : System.Collections.BitArray;
  i              : Integer;

begin
  // Create our bit arrays
  Source := System.Collections.BitArray.Create(4);
  Target  := System.Collections.BitArray.Create(4);

  // Set the values in both arrays
  Source[0] := false;  // 0
  Source[1] := false;  // 0
  Source[2] := true;   // 1
  Source[3] := true;   // 1

  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);

  // Perform a logical NOT of Source into Target :
  Target := Source.⫬  // Note the &

  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.
   Source [0] = 0
   Source [1] = 0
   Source [2] = 1
   Source [3] = 1
  
   Target [0] = 1
   Target [1] = 1
   Target [2] = 0
   Target [3] = 0
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author