CSharp - LINQ Reverse

Introduction

The reverse operator outputs a sequence in the reverse order.

Prototypes

The Reverse Prototype

public static IEnumerable<T> Reverse<T>(
  this IEnumerable<T> source);

Exceptions

ArgumentNullException is thrown if the source argument is null.

Demo

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
class Program//from w  w w. j  a  v  a  2  s .co  m
{
    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);
    }
}

Result

The code prints the codeNames in the reverse order of the order in the codeNames array.