Home  |  Delphi .net Home  |  System.Collections.ArrayList  |  RemoveAt Method
RemoveAt  
Method  
Remove an element from the ArrayList at the specified index position
ArrayList Class
System.Collections NameSpace
CF1.  Procedure RemoveAt ( Index : Integer; ) ;
CF : Methods with this mark are Compact Framework Compatible
Description
The element at the given (0 based) Index position is removed from the ArrayList.
 
The element Count is decremented by 1.
Notes
An exception is thrown if the Index exceeds the Count value.
Microsoft MSDN Links
System.Collections
System.Collections.ArrayList
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

uses
  System.Collections;

var
  List : System.Collections.ArrayList;
  i    : Integer;

begin
  // Create our array list object
  List := ArrayList.Create;

  // Fill it with strings
  List.Add('Hello');
  List.Add('cruel');
  List.Add('World');

  // Display the contents : note the 0 indexing
  for i := 0 to List.Count-1 do
    Console.WriteLine(List.Item[i]);

  // Remove an element
  Console.WriteLine;
  List.RemoveAt(1);

  // Display the contents : note the 0 indexing
  for i := 0 to List.Count-1 do
    Console.WriteLine(List.Item[i]);

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