Export (0) Print
Expand All

Array.Reverse Method (Array, Int32, Int32)

Reverses the sequence of the elements in a range of elements in the one-dimensional Array.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

static member Reverse : 
        array:Array * 
        index:int * 
        length:int -> unit

Parameters

array
Type: System.Array

The one-dimensional Array to reverse.

index
Type: System.Int32

The starting index of the section to reverse.

length
Type: System.Int32

The number of elements in the section to reverse.

ExceptionCondition
ArgumentNullException

array is a null reference (Nothing in Visual Basic).

RankException

array is multidimensional.

ArgumentOutOfRangeException

index is less than the lower bound of array.

-or-

length is less than zero.

ArgumentException

index and length do not specify a valid range in array.

After a call to this method, the element at myArray[i], where i is any index in the array, moves to myArray[j], where j equals (myArray.Length + myArray.GetLowerBound(0)) - (i - myArray.GetLowerBound(0)) - 1.

The Reverse method can be used to reverse a jagged array.

This method is an O(n) operation, where n is length.

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

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft