Failing to use Array.Copy() in my WPF App
Posted
by
Steven Wilson
on Stack Overflow
See other posts from Stack Overflow
or by Steven Wilson
Published on 2012-10-30T04:36:18Z
Indexed on
2012/10/30
5:00 UTC
Read the original article
Hit count: 67
I am a C++ developer and recently started working on WPF. Well I am using Array.Copy() in my app and looks like I am not able to completely get the desired result.
I had done in my C++ app as follows:
static const signed char version[40] = {
'A', 'U', 'D', 'I', 'E', 'N', 'C', 'E', // name
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // reserved, firmware size
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // board number
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // variant, version, serial
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 // date code, reserved
};
unsigned char sendBuf[256] = {};
int memloc = 0;
sendBuf[memloc++] = 0;
sendBuf[memloc++] = 0;
// fill in the audience header
memcpy(sendBuf+memloc, version, 8); // the first 8 bytes
memloc += 16; // the 8 copied, plus 8 reserved bytes
I did the similar operation in my WPF (C#) app as follows:
Byte[] sendBuf = new Byte[256];
char[] version =
{
'A', 'U', 'D', 'I', 'E', 'N', 'C', 'E', // name
'0', '0', '0', '0', '0', '0', '0', '0' , // reserved, firmware size
'0', '0', '0', '0', '0', '0', '0', '0' , // board number
'0', '0', '0', '0', '0', '0', '0', '0' , // variant, version, serial
'0', '0', '0', '0', '0', '0', '0', '0' // date code, reserved
};
// fill in the address to write to -- 0
sendBuf[memloc++] = 0;
sendBuf[memloc++] = 0;
// fill in the audience header
Array.Copy(sendBuf + memloc, version, 8); // the first 8 bytes
memloc += 16;
But it throws me an error at Array.Copy(sendBuf + memloc, version, 8);
as Operator '+' cannot be applied to operands of type 'byte[]' and 'int'
.
How can achieve this???? :) please help :)
© Stack Overflow or respective owner