C# equivalent of python's struct.pack

微笑、不失礼 提交于 2019-12-01 08:28:31

The closest equivalent would probably be to use BinaryWriter writing into a MemoryStream, or BitConverter for a one-off conversion of a single value into a byte array.

If you want to control the endianness of that, you can use my EndianBinaryWriter/EndianBitConverter from MiscUtil. One extra feature of my EndianBitConverter is that you can convert into a specific portion of an existing array, which would help you if you wanted to port struct.pack yourself.

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