I rewrite part of the code from c ++ to c #. In the C ++ code, there are packing and unpacking methods (from the (char) -> array to the structure and vice versa). Accordingly, for this I used memcpy (bufer, struct, size). I was surprised that there is nothing like that in Sharps, but there is a whole zoo of methods that do not understand what they do. Tell me what is better to use in this context?
- the description is similar to binary serialization and deserialization - Grundy
- This can be done by using unsafe code (in particular, fixed size buffers ) and explicit field layout . - Alexander Petrov
|
1 answer
If I'm not mistaken, then in C # there are fewer opportunities to "shoot yourself in the foot", unlike C ++. C # is a higher level language than C ++ or C. Therefore, there may be no direct memory access. Also in C # it is no longer possible to redefine variable types as well as in C ++. And so the C # language is the MS response to Java. And work with variables and pointers there is very similar and different from C ++.
|