变量名 | 类 型 | 静态 | 数组 | 备 注 | destinationArray | 字节集 | | | i | 整数型 | | | j | 整数型 | | |
destinationArray = { 177, 142, 128, 0, 24, 0, 22, 0, 1, 0, 0, 4, 75, 0, 0, 0, 1, 0, 0, 21, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 15, 0, 0, 0, 11, 54, 54, 52, 50, 54, 56, 48, 49, 56, 3, 9, 0, 8, 0, 1, 0, 0, 0, 0, 0, 4, 0, 54, 0, 18, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 20, 0, 29, 1, 2, 0, 25, 2, 81, 202, 74, 171, 102, 232, 10, 228, 210, 121, 146, 26, 206, 60, 61, 254, 226, 55, 136, 21, 31, 69, 54, 141, 0, 0, 0, 0, 0, 0, 0 }变量循环首 (1, 取字节集长度 (destinationArray ), 4, i )j = j + 1 调试输出 (ConvertByteArrayToUInt (destinationArray, i )) 变量循环尾 ()返回 (0 )|
ConvertByteArrayToUInt | 整数型 | | |
V | 字节集 | | | | Offset | 整数型 | | | | 如果真 (Offset + 3 > 取字节集长度 (V )) 返回 (0 )num = 左移 (V [Offset], 24)num = 位或 (num, 左移 (V [Offset + 1 ], 16 )) num = 位或 (num, 左移 (V [Offset + 2 ], 8 )) 返回 (位或 (num, V [Offset + 3 ]))
易语言输出结果:
开始运行被调试程序
* -1316061184 第一个,抓破脑袋想不明白,为什么是负数,往下 看看 C#
* 402658816
* 16777220
* 1258291200
* 16777237
* 150994944
* 0
* 1024
* 251658240
* 188102196
* 842414128
* 825754377
* 524289
* 0
* 262198
* 1179650
* 65536
* 0
* 0
* 0
* 18087965
* 16908313
* 38914634
* -1419319286
* -455968366
* 449723453
* -18729080
* 354370870
* -1929379840
* 0
被调试易程序运行完毕
-------------------------------------------------------------------
byte[] destinationArray = {177, 142, 128, 0, 24, 0, 22, 0, 1, 0, 0, 4, 75, 0, 0, 0, 1, 0, 0,
21, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 15, 0, 0, 0, 11, 54, 54, 52,
50, 54, 56, 48, 49, 56, 3, 9, 0, 8, 0, 1, 0, 0, 0, 0, 0, 4, 0, 54, 0,
18, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 20, 0, 29,
1, 2, 0, 25, 2, 81, 202, 74, 171, 102, 232, 10, 228, 210, 121, 146, 26,
206, 60, 61, 254, 226, 55, 136, 21, 31, 69, 54, 141, 0, 0, 0, 0, 0, 0, 0};
for (int i = 0; i < destinationArray.Length; i += 4)
{
Console.Write(ConvertByteArrayToUInt(destinationArray, i) + "\n");
}
private static uint ConvertByteArrayToUInt(byte[] v, int offset)
{
if ((offset + 4) > v.Length)
{
return 0;
}
uint num = (uint)(v[offset] << 24);
num |= (uint)(v[offset + 1] << 16);
num |= (uint)(v[offset + 2] << 8);
return (num | v[offset + 3]);
}
C# 输出结果: 为什么结果,第一位会不一样,抓破脑袋搞不通
|