Have you ever wanted to simply typecast a byte array to a data structure and then use that data structure like you used to be able to do in C? Well, C# provides a facility to accomplish this. Several months ago I needed to take a byte array 64 bytes long and extract different fields from it. At first it seemed that the only solution was to convert the byte array to a string and then use substrings to get what I needed. To add insult to injury, I then had to take each of the substrings and convert them into the data types that I wanted and then assign the members of my data structre to each of those. Something ain’t right about that!!
http://www.matthew-long.com/2005/10/18/memory-pinning/
很不錯的方法 值得學起來
Recent Comments