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?

4
  • What is TRANSACTIONLOGINFO? You sure it is not an array of structures? Commented Jan 24, 2012 at 7:36
  • TRANSACTIONLOGINFO is a structure Commented Jan 24, 2012 at 8:32
  • objTran contains binary data. Commented Jan 24, 2012 at 8:35
  • @user662285: Well show us what TRANSACTIONLOGINFO looks like... Commented Jan 24, 2012 at 9:39

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.