Jump to content
  • Advertisement
Sign in to follow this  
Mulligan

[.net] Converting a byte array into a single 'long' value

This topic is 4614 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!