1

I have one multi-dimensional array which contains binary data as [3,240]:

byte[,] bData = (byte[,])objTran; // bdata is binary data with [3,240]

which means it has 3 records each from 0,239 and 1,239 and 2,239. Now I am Marshalling this data to copy in TRANSACTIONLOGINFO structure:

GCHandle handle = GCHandle.Alloc(bData, GCHandleType.Pinned);

TRANSACTIONLOGINFO ObjTranInfo = (TRANSACTIONLOGINFO)Marshal.PtrToStructure(
    handle.AddrOfPinnedObject(), typeof(TRANSACTIONLOGINFO));

handle.Free();

But every time ObjTranInfo shows only the first data details. How can I convert the multi-dimensional array to a single-dimensional array and pass to GCHandle to get each data one by one?

Matthew Strawbridge
  • 19,940
  • 10
  • 72
  • 93
Bokambo
  • 4,204
  • 27
  • 79
  • 130

1 Answers1

1

Create a single-dimensional byte array of the right size (in your case 240) and copy the data across a byte at a time using a for loop. Repeat this for every row of the original two-dimensional array.

Matthew Strawbridge
  • 19,940
  • 10
  • 72
  • 93