using NPOI.SS.Formula.Functions; using Org.BouncyCastle.Utilities.Encoders; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Admin.Core.Common.Helper { public class StringChange { public static string bytesToHexStr(byte[] bytes, int iLen)//e.g. { 0x01, 0x01} ---> " 01 01" { string returnStr = ""; if (bytes != null) { for (int i = 0; i < iLen; i++) { returnStr += bytes[i].ToString("X2"); } } return returnStr; } public static int ParseToInt(string str) { int returnInt = 0; if (str == null || str.Trim().Length < 1) { return returnInt; } if (int.TryParse(str, out returnInt)) { return returnInt; } else { return 0; } } public static string BytesToDecimalStr(byte[] bytes, int iLen) { string returnStr = ""; if (bytes != null) { for (int i = 0; i < iLen; i++) { string temp = bytes[i].ToString("X2"); int aa = int.Parse(temp, System.Globalization.NumberStyles.HexNumber); returnStr += temp; } } return returnStr; } } }