The reverse operator outputs a sequence in the reverse order.
The Reverse Prototype
public static IEnumerable<T> Reverse<T>( this IEnumerable<T> source);
ArgumentNullException is thrown if the source argument is null.
using System; using System.Linq; using System.Collections; using System.Collections.Generic; class Program/*w ww . j av a 2 s. c om*/ { static void Main(string[] args) { string[] codeNames = {"Python", "Java", "Javascript", "Bash", "C++", "Oracle"}; IEnumerable<string> items = codeNames.Reverse(); foreach (string item in items) Console.WriteLine(item); } }
The code prints the codeNames in the reverse order of the order in the codeNames array.