Parker's DevEd Blog

Musings on all software development technologies, and education involving computer science and fraud investigation

Marshalling Sample

What is believed to be the correct and safe way to marshal something...

Point p = new Point(10, 10);
IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(p));
try {
    Marshal.StructureToPtr(p, pnt, false);
    Point newP = (Point)Marshal.PtrToStructure(pnt, typeof(Point));
} finally {
    Marshal.FreeHGlobal(pnt);
}

Comments

No Comments