I was wondering if anyone here knows an efficient way to cast an integer to a byte[4]? I’m trying to write an int into MemoryStream, and this thing wants me to give it bytes
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use
BitConverter.GetBytesif you want to convert a primitive type to its byte representation. Just remember to make sure the endianness is correct for your scenario.