CSharp examples for System.Collections.Generic:IEnumerable
Clone IEnumerable and return List
using System.Linq; using System.Collections.Specialized; using System.Collections.Generic; using System;//from w w w . j a v a2s.com public class Main{ public static List<T> Clone<T>(this IEnumerable<T> listToClone) where T : ICloneable { return listToClone.Select(item => (T)item.Clone()).ToList(); } public static List<KeyValuePair<string, string>> ToList(this NameValueCollection items) { if(items == null) return null; var list = new List<KeyValuePair<string, string>>(); for(var i = 0; i < items.Count; i++) { list.Add(new KeyValuePair<string, string>(items.Keys[i],items[i])); } return list; } }