Reverse IEnumerable - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IEnumerable

Description

Reverse IEnumerable

Demo Code


using System.Collections.Generic;
using System.Collections;
using System;//from   w  ww  .ja  v a  2s. c  o m

public class Main{

        public static List<T> Reverse<T>(IEnumerable<T> coll)
        {
            List<T> ret = new List<T>(1);
            foreach (T t in coll)
            {
                ret.Insert(0, t);
            }
            return ret;
        }
}

Related Tutorials