Home  |  Delphi .net Home  |  System.Collections.BitArray  |  GetEnumerator Method
GetEnumerator  
Method  
Gets an enumerator to allow reading the elements of the current BitArray
BitArray Class
System.Collections NameSpace
CF1.  Function GetEnumerator ( ) : IEnumerator;
CF : Methods with this mark are Compact Framework Compatible
Description
Returns an IEnumerator object that allows the contents of the current Bitrray to be read.
 
A call to MoveNext must be performed before a value can be read from the enumerator - the starting position is before the first element.
References
IEnumerator
Microsoft MSDN Links
System.Collections
System.Collections.BitArray
 
 
Geting all elements from an BitArray
program Project1;
{$APPTYPE CONSOLE}

uses
  System.Collections;

var
  MyList     : System.Collections.BitArray;
  Enumerator : IEnumerator;

begin
  // Create our array list object
  MyList := BitArray.Create(4);

  // Fill it
  MyList[0] := false;  // 0
  MyList[1] := true;   // 1
  MyList[2] := true;   // 1
  MyList[3] := false;  // 0

  // Get an enumerator for the BitArray
  Enumerator := MyList.GetEnumerator;

  // Display the array contents using the enumerator
  while Enumerator.MoveNext do
    Console.WriteLine(Enumerator.Current.ToString);

  Console.Readline;
end.
Show full unit code
  False
  True
  True
  False
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author