CSharp examples for System.Collections:ICollection
Transform ICollection to List
using System.Collections.Generic; using System.Collections; using System;/* ww w. j a va 2 s . co m*/ public class Main{ public static List<T> Transform<F, T>(ICollection<F> source) where F : T { if (source == null || source.Count == 0) return new List<T>(); List<T> ret = new List<T>(source.Count); foreach (F f in source) { ret.Add(f); } return ret; } public static List<T> Transform<F, T>(ICollection<F> source, Transformer<F, T> transformer) { if (transformer == null) throw new ArgumentException("transformer"); if (source == null || source.Count == 0) return new List<T>(); List<T> ret = new List<T>(source.Count); foreach (F f in source) { ret.Add(transformer(f)); } return ret; } }