Using CopyMemory in .NET - The Code Project - VB.NET
This tutorial will show you how to use the WIndows API function CopyMemory to populate Class data using a string as input.
In my line of work, I have to deal with several file formats that contain fixed length records. This is probably the fastest, most straight-forward way to read those files because the data is a 'known size'. CopyMemory is ideal for this because parsing data is virtually eliminated.
I'm going to walk you through the entire process and explain as I go, starting with a new ConsoleApplication. You should follow the article using .NET on your own machine. I try to avoid straying from the topic at hand, so when you get to the bolded sections of code, just copy and paste them into your program.
Background
CopyMemory is a function that will copy the contents of one block of memory to a different block of memory without regard to the data type that is stored there. This results in an ultra fast copy of data, especially for objects like Structures, Classes and Strings.