Home  |  Delphi .net Home  |  System.Collections.ArrayList  |  Clear Method
  
Clear  
Method  
Remove all elements from the ArrayList
ArrayList Class
System.Collections NameSpace
CF1.  Procedure Clear ;
CF : Methods with this mark are Compact Framework Compatible
Description
The Clear method is unfortunately named. Rather than clear the element object values, it actually removes all array elements. The Count value is set to 0.
Microsoft MSDN Links
System.Collections
System.Collections.ArrayList
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

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

uses
  System.Collections;

var
  MyList     : System.Collections.ArrayList;

begin
  // Create our sorted List
  MyList := ArrayList.Create(10);  // Capacity set to 10 elements

  // Add entries to it
  MyList.Add('Neil Moffatt');
  MyList.Add(TObject(47));
  MyList.Add(DateTime.Create(1957, 2, 18));

  Console.WriteLine('Count    = ' + MyList.Count.ToString);
  Console.WriteLine('Capacity = ' + MyList.Capacity.ToString);
  Console.WriteLine;
  Console.WriteLine('Clearing the ArrayList :');

  // Clear the SortedList
  MyList.Clear;

  Console.WriteLine;
  Console.WriteLine('Count    = ' + MyList.Count.ToString);
  Console.WriteLine('Capacity = ' + MyList.Capacity.ToString);

  Console.Readline;
end.
   Count    = 3
   Capacity = 10
  
   Clearing the ArrayList :
  
   Count    = 0
   Capacity = 10
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author