public static byte[] int2Byte(int intValue)
{
byte[] b = new byte[4];
for (int i = 0; i < 4; i++) {
b[i] = (byte)(intValue >> 8 * (3 - i) & 0xFF);
} return b;
}
{
byte[] b = new byte[4];
for (int i = 0; i < 4; i++) {
b[i] = (byte)(intValue >> 8 * (3 - i) & 0xFF);
} return b;
}
分别为 0001
0010
0100
1000
结果分别为 (二进制作):
0001
0010
0100
1000
>> n 右移n位,最高位符号位不移
<< n 左移n位,最高位符号位不移
>>> n 右移n位,最高为符号位也移
<<< n 左移n位,最高为符号位也移