| 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
|
|
|
| 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.
| | Show full unit code | Count = 3
Capacity = 10
Clearing the ArrayList :
Count = 0
Capacity = 10
|
| |
|
|
|