C# Array Reverse

To reverse an array in C#, call Array.Reverse() method and pass the array as argument. The order of elements in this array is reversed.

Example

In the following example, we take an array of integers arr of length 3, and reverse this array using Array.Reverse().

Program.cs

</>
Copy
using System;

namespace CSharpExamples {
    class Program {
        static void Main(string[] args) {
            int[] arr = { 3, 6, 9 };
            Array.Reverse(arr);
            for (int i = 0; i < arr.Length; i++) {
                Console.WriteLine( "arr[{0}]: {1}", i, arr[i] );
            }
        }
    }
}

Output

arr[0]: 9
arr[1]: 6
arr[2]: 3

Conclusion

In this C# Tutorial, we learned how to reverse an array, with examples.