Created
August 23, 2012 09:06
-
-
Save hmemcpy/3434473 to your computer and use it in GitHub Desktop.
Better way to indian?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// converts 0x00010203 to a byte array, containing: 0x03, 0x02, 0x01, 0x00 | |
public static byte[] ToBigEndian(int data) | |
{ | |
var result = new byte[4]; | |
result[0] = (byte)data; | |
result[1] = (byte)(((uint)data >> 8) & 0xFF); | |
result[2] = (byte)(((uint)data >> 16) & 0xFF); | |
result[3] = (byte)(((uint)data >> 24) & 0xFF); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment