Remove the element at the specified index of the ArrayList in CSharp

Description

The following code shows how to remove the element at the specified index of the ArrayList.

Example


using System;//  ww  w .j av a 2  s  . com
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" );

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


      myAL.RemoveAt( 5 );

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

The code above generates the following result.





















Home »
  C# Tutorial »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary