ListTool.cs 919 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Y.Utils.Net20.ListUtils
  5. {
  6. public sealed class ListTool
  7. {
  8. public static bool IsNullOrEmpty(List<string> list)
  9. {
  10. if (list != null && list.Count > 0)
  11. return false;
  12. return true;
  13. }
  14. public static bool IsNullOrEmpty<T>(List<T> list)
  15. {
  16. if (list != null && list.Count > 0)
  17. return false;
  18. return true;
  19. }
  20. public static bool IsNullOrEmpty<T>(IEnumerable<T> list)
  21. {
  22. if (list != null)
  23. {
  24. foreach(var l in list)
  25. {
  26. return false;
  27. }
  28. }
  29. return true;
  30. }
  31. public static bool HasElements<T>(IEnumerable<T> list)
  32. {
  33. return !IsNullOrEmpty(list);
  34. }
  35. }
  36. }