using System; using System.Collections.Generic; using Mono; #if !NET_3_5 && !NET_4_0 namespace System.Linq { static class Enumerable { public static IEnumerable Select (this IEnumerable self, Func selector) { foreach (var item in self) yield return selector (item); } public static IEnumerable Where (this IEnumerable self, Func predicate) { foreach (var item in self) if (predicate (item)) yield return item; } public static List ToList (this IEnumerable self) { return new List (self); } public static T [] ToArray (this IEnumerable self) { return self.ToList ().ToArray (); } public static T First (this IEnumerable self) { using (var enumerator = self.GetEnumerator ()) { if (!enumerator.MoveNext ()) throw new InvalidOperationException (); return enumerator.Current; } } } } #endif