How do you reverse the order of a byte array in c#?
You can use the Array. Reverse() method.
Description. The Byte Reversal block changes the order of the bytes in data that you input to the block. Use this block when a process communicates between target computers that use different endianness, such as between Intel® processors that are little endian and other processors that are big endian.
Reverse Bits in C++ answer := answer OR (n AND i), and shift it to the left i times. n := n after right shifting 1 bit.
You could use the Array.Reverse
method:
byte[] bytes = GetTheBytes();
Array.Reverse(bytes, 0, bytes.Length);
Or, you could always use LINQ and do:
byte[] bytes = GetTheBytes();
byte[] reversed = bytes.Reverse().ToArray();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With