LINQ Reverse Query Operator

By Peter Bromberg

Inverts the order of the elements in a sequence.

char[] apple = { 'a', 'p', 'p', 'l', 'e' };

             char[] reversed = apple.Reverse().ToArray();

             foreach (char chr in reversed)
            {
               Console.Write(chr + " ");
            }
           Console.WriteLine();

            /*
             This code produces the following output:

             e l p p a
             */

LINQ Reverse Query Operator  (837 Views)