[.net] Converting a byte array into a single 'long' value
I'm using C# and want to send a 'long' value over the network. All my network traffic deals with sending arrays of bytes. So basically, I need to figure out how to decompose a 'long' value into a series of byte values, then reassemble them on the other side of the connection.
Ive never done used bitwise operators with c# (i have with C++), and I'm not sure what I should be looking for.
I know I could convert it to ASCII and send it, but I'm trying to stay purely with byte arrays.
Thanks.
I think you're looking for the BitConverter class. It has a GetBytes method for converting from a long (Int64) to a byte array and a ToInt64 method to convert back.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement