I get an array of bytes, I need to decouple it with C # struct. I know the type of structure, it has several lines. The lines in the byte array look like this: the first two bytes are the length of the string, and then the string itself. I do not know the length of the strings. I know its unicode!
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public class User { int Id;//should be 1 String UserName;//should be OFIR String FullName;//should be OFIR }
an array of bytes looks like this: 00,00,01,00, 00,00,08,00, 4F, 00,46,00,49,00,52,00, 00,00,08,00, 4F, 00,46 , 00.49.00.52.00,
I also found this link with the same problem: loading binary data into a structure
Thanks to everyone, Ophir
c # struct marshalling unmarshalling
Ofir
source share