文件名称:byte数组转uint
文件大小:748B
文件格式:TXT
更新时间:2021-02-06 05:10:06
byte[] to uint
public static uint ByteToInt(byte[] b) { uint u = 0; int startIndex = 0; if (b.Length == 8) u = (uint)(b[startIndex + 0] << 56 | b[startIndex + 1] << 48 | b[startIndex + 2] << 40 | b[startIndex + 3] << 32 | b[startIndex + 4] << 24 | b[startIndex + 5] << 16 | b[startIndex + 6] << 8 | b[startIndex + 7]); else if (b.Length == 4) u = (uint)(b[startIndex + 0] << 24 | b[startIndex + 1] << 16 | b[startIndex + 2] << 8 | b[startIndex + 3]); else if (b.Length == 2) u = (uint)(b[startIndex + 0] << 8 | b[startIndex + 1]); else u = (uint)(b[startIndex + 0]); return u; }