In C #, you can do something similar, but then you will need to apply a lot of attributes to the structure so that you accurately determine how it stacks in memory. By default, the JIT compiler controls how structure elements are placed in memory, which usually means that they are rearranged and supplemented for the most efficient layout, given the speed and memory usage.
The easiest way is to use BinaryReader to read the individual elements of the structure in the file and put the values ββin the properties of the class, i.e. manually deserialize the data into an instance of the class.
Usually he reads a file that is the neck of the bottle in this operation, so the small overhead of reading individual items does not affect performance noticeably.
Guffa
source share