C# ArrayList RemoveAt

Description

ArrayList RemoveAt removes the element at the specified index of the ArrayList.

Syntax

ArrayList.RemoveAt has the following syntax.


public virtual void RemoveAt(
  int index
)

Parameters

ArrayList.RemoveAt has the following parameters.

  • index - The zero-based index of the element to remove.

Returns

ArrayList.RemoveAt method returns

Example

The following code example shows how to remove elements from the ArrayList.


//from   w w w .j  a  v a  2s  . c om
using System;
using System.Collections;
public class SamplesArrayList  {

   public static void Main()  {
      ArrayList myAL = new ArrayList();
      myAL.Add( "1" );
      myAL.Add( "2" );
      myAL.Add( "3" );
      myAL.Add( "4" );
      myAL.Add( "5" );
      myAL.Add( "6" );
      myAL.Add( "7" );
      myAL.Add( "8" );
      myAL.Add( "9" );

      myAL.RemoveAt( 5 );

      foreach ( Object obj in myAL )
         Console.WriteLine(obj );
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections »




ArrayList
BitArray
Comparer
Hashtable
Queue
SortedList
Stack