Exemple #1
0
        /// <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);
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        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));
        }
Exemple #4
0
        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));
        }
Exemple #5
0
 /// <summary>
 /// Hex字符串转换成byte数组
 /// </summary>
 /// <param name="S"></param>
 /// <returns></returns>
 public static byte[] ToHexBytes(this string S)
 {
     return(TxtToolBLL.GetBytesByHexStringData(S));
 }
Exemple #6
0
 public static byte[] Cof_ToBytesX(this long D, int Len)
 {
     byte[] Dbytes = new byte[Len];
     TxtToolBLL.int2Byte(D, Dbytes, 0, Len, true);
     return(Dbytes);
 }
Exemple #7
0
 public static byte[] Cof_To2BytesX(this int D)
 {
     byte[] Dbytes = new byte[2];
     TxtToolBLL.int2Byte(D, Dbytes, 0, 2, true);
     return(Dbytes);
 }
Exemple #8
0
 public static byte[] Cof_To4Bytes(this int D)
 {
     byte[] Dbytes = new byte[4];
     TxtToolBLL.int2Byte(D, Dbytes, 0, 4, false);
     return(Dbytes);
 }
Exemple #9
0
 /// <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));
 }
Exemple #10
0
 /// <summary>
 /// 转换成16进制字符串数据 不带空格
 /// </summary>
 /// <param name="Bs"></param>
 /// <returns></returns>
 public static string ToHexStringData(this byte[] Bs)
 {
     return(TxtToolBLL.GetBytesHexStrD(Bs));
 }
Exemple #11
0
 /// <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)));
 }
Exemple #12
0
 /// <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));
 }