using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace EC.Utils.Helper { public class ByteHelper { public static string IntToHex(int i) { return Convert.ToString(i, 16); } /// /// int 类型转回为 byte[] /// /// /// public static byte[] IntToByte2(int i) { byte[] a = new byte[2]; a[0] = (byte)(i >> 8); a[1] = (byte)i; return a; } /// /// 截取byte 数组 /// /// /// /// /// public static byte[] SubArr(byte[] frombyte, int begIndex, int lenth) { byte[] subByte = new byte[lenth]; int icount = (begIndex + lenth); for (int x = begIndex; x< icount; x++) { subByte[x - begIndex] = frombyte[x]; } return subByte; } } }