What's the best method for..

M

minimega

Hello to all NG. I'm not able to find a "elegant" way to solve the
following problem:
I've 4 double variables, and I want to copy them in an array of byte[]
with lenght of 32 (4 * 8).

I've to take the first variable and put it in the first 8 bytes of my
array, then take the second and put it in the second 8 bytes of array
and so on.. the resulting array of bytes will be passed (as pointer) to
a C++ DLL that will read the values in it.

How can I do this?

Thanks,
Massimo
 
D

Davidino79

How can I do this?
try something like this
byte[] c = new byte[8];
unsafe
{
double doppio = 5.0;
byte * p;
for ( int i = 0; i < 8; i++)
{
p = (byte*)& doppio + i;
c = *p;
}
}



Bye davide
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top