This only works with int
, float
, byte
, char
and double
, but you can use Marshal.Copy()
to move data from a fixed array to a managed array.
Example:
class Program { static void Main(string[] args) { MyStruct s = new MyStruct(); s.MyUints = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; int[] chk = s.MyUints;
source share