开发者

How to reverse the order of a byte array in c#?

开发者 https://www.devze.com 2023-03-01 03:48 出处:网络
How do you reverse the order of a b开发者_运维技巧yte array in c#?You could use the Array.Reverse method:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消