Main Site Documentation

Packed Struct to byte array


#1

Hi,

I’m looking for a suggestion as to the best method of converting a struct to an array of bytes?

In the full .NET we normally use attributes on the struct to make it packed:

[StructLayout(LayoutKind.Sequential, Pack = 1)]

and a function that Marshal to copy to a byte array.

But… there is no StructLayout to create a packed array in NETMF.

Any suggestions?

The best I can see is to use InsertValueIntoArray.

Thank you