BitConverter 类,可以从byte数组中转换 但是要注意尾序,也就是你要清楚哪个字节是高位,哪个字节是低位。 BitConverter 一般以小尾方式处理,这是因为跑windows 的机器通常是小尾的。
追答:
uint 是一种类型,并不是指定的16进制或10进制。
uint 在打印的时候,用x 去格式化就是16进制显示方式,不加就是10进制。而存储方式只有一种,那就是二进制。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
byte
aa=0x00;
bb=0xf;
cc=0x1;
dd=0x00;
byte
[] bytes =
new
[]{aa,bb,cc,dd};
uint
num = BitConverter.ToUInt32(bytes,0);
Console.WriteLine(
"0x{0:X8}"
,num);
"{0}"
[] bytes2 =
[]{dd,aa};
num = BitConverter.ToUInt32(bytes2,0);
相关推荐 |