Reverse an int array in CSharp
Description
The following code shows how to reverse an int array.
Example
//w w w .j a v a2s . c o m
using System;
using System.Collections.Generic;
using System.Linq;
public class MainClass {
public static void Main() {
int[] numbers = { 10, 9, 8, 7, 6 };
IEnumerable<int> reversed = numbers.Reverse(); // { 6, 7, 8, 9, 10 }
foreach(int i in reversed){
Console.WriteLine(i);
}
}
}
The code above generates the following result.