What's the best method for..

  • Thread starter Thread starter minimega
  • Start date Start date
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
 
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
 
Back
Top