换句话说,在指定结构时如何实现与C中相同的控制级别,而不必求助于Stream上的Read/WriteBytes序列?谢谢.解决方案这是一个文章,它说明了实现此目标的一种方法.但是,如果您要使用意识形态的.NET,则 BinaryReader 是要走的路.如果不强制使用格式,并且可以控制格式,则还可以使用 BinaryFormatter ,但它产生的内容不可互操作.Greetings,What is the most idiomatic way of performing serialization/deserialization of binary custom formats? For example, how would you read a file with a set of headers specified in bytes (e.g. 4, 4, 16, 4, 8, 8, 4, 16) with no padding, with mixed integer/byte[] types?In other words, how do you achieve the same level of control as in C when specifying a structure, without having to resort to sequences of Read/WriteBytes over a Stream?Thanks. 解决方案 Here's an article which illustrates one method to achieve this. But if you want ideomatic .NET then BinaryReader is the way to go. If the format is not imposed and you have control over it you could also use BinaryFormatter but what it produces is not interoperable. 这篇关于自定义二进制文件的惯用C#反序列化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-02 10:32