Reverses the sequence of the elements in the entire one-dimensional Array.
- array
- The one-dimensional Array to reverse.
Type Reason ArgumentNullException array is null. RankException array has more than one dimension.
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.
This method is an O(n) operation, where n is the Array.Length of array.
As the following example shows, the Array.Reverse(Array) method can be used to reverse a jagged array. It initializes a jagged array with one element for each month of the current year in the current culture's calendar. Each element contains an array with as many elements as that month has days. The example displays the contents of the array, calls the Array.Reverse(Array) method, and then displays the contents of the reversed array.
code reference: System.Array.Reverse#1