I have big arrays of KeyValuePair<DateTime,decimal>
. I know that in memory the array is contiguous since KVP is a value type, DateTime is effectively an Int64, and decimal is an array of 4 ints (and that won't change). However, DateTime is not blittable, and decimal is not primitive.
Is there any way to abuse type system and get an unsafe pointer to the array and work with it as bytes? (GCHandle.Alloc
cannot work with these two types when they are a part of a structure, but works OK with arrays of those type.)
(If you are interested why, I convert the array now manually to what I believe is 1-to-1 byte[] representation, and it is slow)