How do you reverse the order of a b开发者_运维技巧yte array in c#?
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();
Array.Reverse(byteArray);
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.
You can use Array.Reverse. Also please go through this for more information.
You can use the Array.Reverse()
method.
精彩评论