开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜