Mono Class Library: System.Array Overview | Members

System.Array.Reverse Method

Reverses the sequence of the elements in the specified range of the specified one-dimensional Array. [Edit]

[System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.MayCorruptInstance, System.Runtime.ConstrainedExecution.Cer.MayFail)]
public static void Reverse (Array array, int index, int length)

Parameters

array
The one-dimensional Array to reverse. [Edit]
index
A int that contains the index at which reversing starts. [Edit]
length
A int that contains the number of elements to reverse. [Edit]

Exceptions

TypeReason
ArgumentNullExceptionarray is null. [Edit]
RankExceptionarray is multidimensional. [Edit]
ArgumentOutOfRangeException

index < array.GetLowerBound(0).

length < 0.

[Edit]
ArgumentExceptionindex and length do not specify a valid range in array (i.e. index + length > array.GetLowerBound(0) + array.Length). [Edit]

Remarks

Documentation for this section has not yet been entered. [Edit]

Example

The following example demonstrates the Array.Reverse(Array) method.

C# Example
using System;
public class ArrayReverseExample {
   public static void Main() {
      string[] strAry = { "one", "two", "three" };
      Console.Write( "The elements of the array are:");
      foreach( string str in strAry )
         Console.Write( " {0}", str );
      Array.Reverse( strAry );
      Console.WriteLine();
      Console.WriteLine( "After reversing the array," );
      Console.Write( "the elements of the array are:");
      foreach( string str in strAry )
         Console.Write( " {0}", str );
   }
}

The output is

The elements of the array are: one two three
After reversing the array,
the elements of the array are: three two one

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0