__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
In .NET the char data type is is 16bit, most other languages it is 8bit. You will also need to watch out for that.
sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
Because of this unmanaged attribute a size of char is 8 bits.
[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi, Size = 14)]
struct xyz
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
public char[] localc;
short localshort;
}
...
...
xyz p = new xyz();
int size=Marshal.SizeOf(p);
..
So the size of struct is 14 bytes.
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241