ToolUtils.cs 840 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace IMCS_CCS.Utils
  7. {
  8. public class ToolUtils
  9. {
  10. public static string AddressConvertDBW(string Address)
  11. {
  12. string[] sArray = Address.Split('.');
  13. return sArray[0] + ".DBW" + sArray[1];
  14. }
  15. public static byte[] ReturnBtyesWtitString(string value, int byteleng = 30)
  16. {
  17. byte[] bt = new byte[byteleng];
  18. byte[] item = Encoding.Default.GetBytes(value.Clone().ToString());
  19. Array.Copy(item, bt, item.Length);
  20. return bt;
  21. }
  22. public static string ReturnStringByBytes(byte[] value)
  23. {
  24. return System.Text.Encoding.Default.GetString(value).Replace("\0", "");
  25. }
  26. }
  27. }