C# ArrayList Reverse(Int32, Int32)

Description

ArrayList Reverse(Int32, Int32) reverses the order of the elements in the specified range.

Syntax

ArrayList.Reverse(Int32, Int32) has the following syntax.


public virtual void Reverse(
  int index,
  int count
)

Parameters

ArrayList.Reverse(Int32, Int32) has the following parameters.

  • index - The zero-based starting index of the range to reverse.
  • count - The number of elements in the range to reverse.

Returns

ArrayList.Reverse(Int32, Int32) method returns

Example

The following code example shows how to reverse the sort order of the values in a range of elements in an ArrayList.


using System;//from  w w  w  .  j a v a 2s . c om
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.Reverse( 1, 3 );
 
      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