coldfusion244 Posted April 18, 2005 Posted April 18, 2005 I need to use a 32bit datatype that is in the order of big-endian. I'm unsure of how .NET order's it's data, depending on if it's big/little I could change the data it must hold. Does anyone know what scheme MS uses? The data I'm using is 0x7E. Quote -Sean
HJB417 Posted April 19, 2005 Posted April 19, 2005 little endian when I was working on itunes related stuff, I use the following method to convert the value private static int Reverse(int value) { byte[] data = BitConverter.GetBytes(value); Array.Reverse(data); return BitConverter.ToInt32(data, 0); } Quote
coldfusion244 Posted April 19, 2005 Author Posted April 19, 2005 little endian when I was working on itunes related stuff, I use the following method to convert the value private static int Reverse(int value) { byte[] data = BitConverter.GetBytes(value); Array.Reverse(data); return BitConverter.ToInt32(data, 0); } Nice, thanks again HJB! Quote -Sean
HJB417 Posted April 19, 2005 Posted April 19, 2005 Also, you can use BitConverter.IsLittleEndian incase you use something like mono or dotgnu. private static int Reverse(int value) { if(!BitConverter.IsLittleEndian) return value; byte[] data = BitConverter.GetBytes(value); Array.Reverse(data); return BitConverter.ToInt32(data, 0); } Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.