CSharp examples for System.Collections.Generic:IEnumerable
Create List from IEnumerable
using System.Collections.Generic; using System.Collections; using System;/*ww w .j a va 2s.co m*/ public class Main{ public static IList CreateList(IEnumerable collection) { ArrayList ret = new ArrayList(); if (collection != null) { foreach (object o in collection) { ret.Add(o); } } return ret; } public static List<T> CreateList<T>(IEnumerable collection) { List<T> ret = new List<T>(); if (collection != null) { foreach (object o in collection) { ret.Add((T)o); } } return ret; } }