You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
975 B

3 years ago
  1. #if NET20
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. namespace System.Linq
  6. {
  7. /// <summary></summary>
  8. public static class Enumerable
  9. {
  10. /// <summary></summary>
  11. public static List<T> ToList<T>(this IEnumerable<T> items)
  12. {
  13. var list = new List<T>();
  14. foreach (var item in list) list.Add(item);
  15. return list;
  16. }
  17. /// <summary></summary>
  18. public static T[] ToArray<T>(this IEnumerable<T> items)
  19. {
  20. return ToList(items).ToArray();
  21. }
  22. /// <summary></summary>
  23. public static List<TResult> Select<TSource, TResult>(this IEnumerable<TSource> items, Func<TSource, TResult> selector)
  24. {
  25. if (items == null) return new List<TResult>();
  26. var list = new List<TResult>();
  27. foreach (var item in items) list.Add(selector.Invoke(item));
  28. return list;
  29. }
  30. }
  31. }
  32. #endif