How to

reverse collection

Published: 30. September 2011 | Updated: 30. September 2011
License: Microsoft Public License (MS-PL)
Categories: Collections
Tags: C# Collections
Was this snippet helpful for you? YESYES / NONO

Import namespace

using System.Linq;

Code

IEnumerable<int> collection = new int[] { 1, 2, 3, 4, 5 };
collection = collection.Reverse();

foreach (int i in collection)
{
    Console.WriteLine(i);
}
Send us feedback about this snippet »



Related Snippets: