StringTool.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. //############################################################
  2. // https://github.com/yuzhengyang
  3. // author:yuzhengyang
  4. //############################################################
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Text;
  8. using Y.Utils.DataUtils.Collections;
  9. namespace Y.Utils.DataUtils.StringUtils
  10. {
  11. public class StringTool
  12. {
  13. public static bool IsNullOrWhiteSpace(string str)
  14. {
  15. if (str == null)
  16. return true;
  17. if (str.Trim().Length == 0)
  18. return true;
  19. return false;
  20. }
  21. public static int Split(string str, char separator, out string[] result)
  22. {
  23. if (!string.IsNullOrWhiteSpace(str))
  24. {
  25. string[] list = str.Split(separator);
  26. if (ListTool.HasElements(list))
  27. {
  28. result = list;
  29. return result.Length;
  30. }
  31. }
  32. result = null;
  33. return 0;
  34. }
  35. }
  36. }