/// <summary> /// 去掉前面的0 /// </summary> /// <param name="Bs"></param> /// <param name="Index"></param> /// <param name="offset"></param> /// <returns></returns> public static string ToHexStringDataUNF0(this byte[] Bs, int Index, int offset) { string s = TxtToolBLL.GetBytesHexStrD(Bs, Index, offset).TrimStart('0'); if (string.IsNullOrEmpty(s)) { return("0"); } return(s); }
public static uint Cof_ToUint(this byte[] Bs, int index, int length) { long l = TxtToolBLL.byte2Int(Bs, index, length, false); if (l > uint.MaxValue) { return(0); } return(Convert.ToUInt32(l)); }
public static short Cof_ToShort(this byte[] Bs, int index, int length) { long l = TxtToolBLL.byte2Int(Bs, index, length, false); if (l > short.MaxValue) { return(Convert.ToInt16((l & 0x7fff) - short.MaxValue - 1)); } return(Convert.ToInt16(l)); }
public static int Cof_ToInt(this byte[] Bs, int index, int length, bool bigOrsmall) { long ii = TxtToolBLL.byte2Int(Bs, index, length, bigOrsmall); if (ii >= int.MaxValue) { return(0); } return(Convert.ToInt32(ii)); }
/// <summary> /// Hex字符串转换成byte数组 /// </summary> /// <param name="S"></param> /// <returns></returns> public static byte[] ToHexBytes(this string S) { return(TxtToolBLL.GetBytesByHexStringData(S)); }
public static byte[] Cof_ToBytesX(this long D, int Len) { byte[] Dbytes = new byte[Len]; TxtToolBLL.int2Byte(D, Dbytes, 0, Len, true); return(Dbytes); }
public static byte[] Cof_To2BytesX(this int D) { byte[] Dbytes = new byte[2]; TxtToolBLL.int2Byte(D, Dbytes, 0, 2, true); return(Dbytes); }
public static byte[] Cof_To4Bytes(this int D) { byte[] Dbytes = new byte[4]; TxtToolBLL.int2Byte(D, Dbytes, 0, 4, false); return(Dbytes); }
/// <summary> /// 转换成16进制字符串数据 /// </summary> /// <param name="Bs"></param> /// <param name="Index"></param> /// <param name="offset"></param> /// <returns></returns> public static string ToHexStringData(this byte[] Bs, int Index, int offset) { return(TxtToolBLL.GetBytesHexStrD(Bs, Index, offset)); }
/// <summary> /// 转换成16进制字符串数据 不带空格 /// </summary> /// <param name="Bs"></param> /// <returns></returns> public static string ToHexStringData(this byte[] Bs) { return(TxtToolBLL.GetBytesHexStrD(Bs)); }
/// <summary> /// 小头模式 /// </summary> /// <param name="Bs"></param> /// <param name="index"></param> /// <param name="length"></param> /// <returns></returns> public static int Cof_ToIntX(this byte[] Bs, int index, int length) { return(Convert.ToInt32(TxtToolBLL.byte2Int(Bs, index, length, true))); }
/// <summary> /// 将小头模式INT转换成长整形 /// </summary> /// <param name="Bs"></param> /// <param name="index"></param> /// <param name="length"></param> /// <returns></returns> public static long ToLongX(this byte[] Bs, int index, int length) { return(TxtToolBLL.byte2Int(Bs, index, length, true)); }