MemoryMarshal.Cast on a struct with array of known fixed size
I'm wondering if there is some way to marshal a byte array into a struct that is known to be of fixed size, or has known length values via other fields:
Althought due to MarshalAs it should be known that it's up to 4 elements this wouldn't work due to the array being recognized as a pointer/reference type.
Is there a way to do this without having to enable unsafe and abuse the fixed keyword?
Althought due to MarshalAs it should be known that it's up to 4 elements this wouldn't work due to the array being recognized as a pointer/reference type.
Is there a way to do this without having to enable unsafe and abuse the fixed keyword?