日期:2014-05-18 浏览次数:20894 次
byte[] result = BitConverter.GetBytes(255);
public void changeEndToStart(byte[] bt, int size) { int i = 0; int half = size / 2; byte b; for (i = 0; i < half; i++) { b = bt[i]; bt[i] = bt[size - i - 1]; bt[size - i - 1] = b; } }
byte[] result = BitConverter.GetBytes(255); changeEndToStart(result,4) //得到的result是这个结果:result{0,0,0,255}
byte[] result = BitConverter.GetBytes(255).Reverse().ToArray() ;
------解决方案--------------------
public static byte[] IntToByteArray(int value) { byte[] array = new byte[4]; for (int i = 3; i >= 0; i--) { array[i] = (byte)(value & 0xff); value = value >> 8; } return array; }