2 using System.Runtime.InteropServices;
7 [StructLayout (LayoutKind.Sequential)]
8 public struct BlittableStruct {
13 public unsafe static int Main () {
14 BlittableStruct ss = new BlittableStruct ();
15 int size = Marshal.SizeOf (typeof (BlittableStruct));
17 Console.WriteLine ("BlittableStruct:" + size);
21 IntPtr p = Marshal.AllocHGlobal (size);
25 Marshal.StructureToPtr (ss, p, false);
26 Type t = ss.GetType ();
28 if (Marshal.ReadInt32 (p, 0) != 123)
30 if (Marshal.ReadInt32 (p, 4) != 124)
33 BlittableStruct cp = (BlittableStruct)Marshal.PtrToStructure (p, ss.GetType ());