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

有些话、适合烂在心里 提交于 2019-12-18 14:56:44

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!