CSharp examples for System.Collections.Generic:IList
Sorts the Ilist.
using System.Text; using System.Collections.Generic; using System.Collections; using System;/*w w w.j a va 2s.co m*/ public class Main{ ///<summary> ///</summary> ///<param name="collection"></param> ///<typeparam name="T"></typeparam> ///<returns>A new sorted IList that has all the items in the <paramref name="collection"/></returns> ///<param name="sortExpression"></param> public static IList<T> Sort<T>(IEnumerable<T> collection, string sortExpression) { List<T> retVal = new List<T>(collection); retVal.Sort(new GenericComparer<T>(sortExpression)); return retVal; } ///<summary> ///</summary> ///<param name="collection"></param> ///<typeparam name="T"></typeparam> ///<returns>A new sorted IList that has all the items in the <paramref name="collection"/></returns> public static IList<T> Sort<T>(IEnumerable<T> collection) { List<T> retVal = new List<T>(collection); retVal.Sort(); return retVal; } /// <summary> /// Sorts the Ilist. /// </summary> /// <param name="collection">The collection.</param> ///<returns>A new sorted IList that has all the items in the <paramref name="collection"/></returns> public static IList Sort(ICollection collection) { ArrayList temp = new ArrayList(collection); temp.Sort(); return temp; } }