问题
How do you reverse the order of a byte array in c#?
回答1:
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();
回答2:
Array.Reverse(byteArray);
回答3:
you can use the linq method: MyBytes.Reverse()
as well as the Array.Reverse()
method.
Which one you should use depends on your needs.
The main thing to be aware of is that the linq version will NOT change your original. the Array version will change your original array.
回答4:
You can use Array.Reverse. Also please go through this for more information.
回答5:
You can use the Array.Reverse() method.
来源:https://stackoverflow.com/questions/5784365/how-to-reverse-the-order-of-a-byte-array-in-c