I have the following .NET value types:
[StructLayout(LayoutKind.Sequential)]
public struct Date
{
public UInt16 V;
}
[StructLayout(LayoutKind.Sequential
Two things:
StructLayout(Sequential)
does not guarantee packing. You might want to use Pack=1
, otherwise 32 and 64bit platforms might be different.
and string is a reference, not a pointer. If the string length is always fixed, you might want to use fixed char arrays:
public struct MyArray // This code must appear in an unsafe block
{
public fixed char pathName[128];
}