如题
谢谢

解决方案 »

  1.   

    此方法使用 Array.Reverse 将元素的顺序反转,从而使得 ArrayList [i](其中 i 表示该范围内的任何索引)处的元素移到 ArrayList [j](其中 j 等于 index + index + count - i - 1)。
    using System;
    using System.Collections;
    public class SamplesArrayList  {   public static void Main()  {      // Creates and initializes a new ArrayList.
          ArrayList myAL = new ArrayList();
          myAL.Add( "The" );
          myAL.Add( "quick" );
          myAL.Add( "brown" );
          myAL.Add( "fox" );
          myAL.Add( "jumps" );
          myAL.Add( "over" );
          myAL.Add( "the" );
          myAL.Add( "lazy" );
          myAL.Add( "dog" );      // Displays the values of the ArrayList.
          Console.WriteLine( "The ArrayList initially contains the following values:" );
          PrintValues( myAL );      // Reverses the sort order of the values of the ArrayList.
          myAL.Reverse();      // Displays the values of the ArrayList.
          Console.WriteLine( "After reversing:" );
          PrintValues( myAL );
       }   public static void PrintValues( IEnumerable myList )  {
          foreach ( Object obj in myList )
             Console.WriteLine( "   {0}", obj );
          Console.WriteLine();
       }}
    /* 
    This code produces the following output.The ArrayList initially contains the following values:
       The
       quick
       brown
       fox
       jumps
       over
       the
       lazy
       dogAfter reversing:
       dog
       lazy
       the
       over
       jumps
       fox
       brown
       quick
       The
    */