using System; using System.Collections.Generic; #if !NET_3_5 && !NET_4_0 namespace System { delegate TResult Func (T t); } namespace System.Runtime.CompilerServices { [AttributeUsage (AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)] sealed class ExtensionAttribute : Attribute { } } 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 T First (this IEnumerable self) { using (var enumerator = self.GetEnumerator ()) { if (!enumerator.MoveNext ()) throw new InvalidOperationException (); return enumerator.Current; } } } } #endif