Reading and writing integers to file in big-endian order


I need to read and write integers (4 byte) from/to a file in big-endian order.  What is the best way to change the byte order of an integer in VB.NET?  I am writing a file with unicode strings and that part was easy using the Encoding object with a BinaryReader and BinaryWriter but the integer values are more difficult.

Thanks in advance,
Who is Participating?
gregasmConnect With a Mentor Commented:
Use the BitConverter class.
big-endian?, the smallest first and the biggest last?
rkellowAuthor Commented:
The high-order byte first down to the low-order (big-endian).  This is the opposite of how Windows (Intel platforms) store values (little-endian).
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.