CollectionHelper.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. namespace HTEXLib.COMM.Helpers
  6. {
  7. public static class CollectionHelper
  8. {
  9. /// <summary>
  10. /// 判断集合是否为空
  11. /// </summary>
  12. /// <param name="collection"></param>
  13. /// <returns></returns>
  14. public static bool IsEmpty(this ICollection collection)
  15. {
  16. if (collection != null && collection.Count > 0)
  17. {
  18. return false;
  19. }
  20. else
  21. {
  22. return true;
  23. }
  24. }
  25. /// <summary>
  26. /// 判断集合是否不为空
  27. /// </summary>
  28. /// <param name="collection"></param>
  29. /// <returns></returns>
  30. public static bool IsNotEmpty(this ICollection collection)
  31. {
  32. if (collection != null && collection.Count > 0)
  33. {
  34. return true;
  35. }
  36. else
  37. {
  38. return false;
  39. }
  40. }
  41. }
  42. }