byte[] b = {0x68, 0x01,0x01,0x02}怎么转成int的0x68010102
1个回答
展开全部
using System;
public class Test
{
public static void Main()
{
byte[] ary = {0x68, 0x01,0x01,0x02};
int value;
int offset = 0;
value = (int) ((ary[offset]&0xFF)
| ((ary[offset+1]<<8) & 0xFF00)
| ((ary[offset+2]<<16)& 0xFF0000)
| ((ary[offset+3]<<24) & 0xFF000000));
Console.WriteLine(value);
}
}
结果是33620328
这是offset=0的情况,你这个肯定不是0
public class Test
{
public static void Main()
{
byte[] ary = {0x68, 0x01,0x01,0x02};
int value;
int offset = 0;
value = (int) ((ary[offset]&0xFF)
| ((ary[offset+1]<<8) & 0xFF00)
| ((ary[offset+2]<<16)& 0xFF0000)
| ((ary[offset+3]<<24) & 0xFF000000));
Console.WriteLine(value);
}
}
结果是33620328
这是offset=0的情况,你这个肯定不是0
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询