
我在我的C应用程序中完成了如下 *** 作:
static const signed char version[40] = {'A','U','D','I','E','N','C',// name 0,// reserved,firmware size 0,// board number 0,// variant,version,serial 0,0 // date code,reserved};unsigned char sendBuf[256] = {};int memloc = 0;sendBuf[memloc++] = 0;sendBuf[memloc++] = 0;// fill in the audIEnce headermemcpy(sendBuf+memloc,8); // the first 8 bytesmemloc += 16; // the 8 copIEd,plus 8 reserved bytes 我在我的WPF(C#)应用程序中执行了类似的 *** 作,如下所示:
Byte[] sendBuf = new Byte[256];char[] version = { 'A',// name '0','0',firmware size '0',// board number '0',serial '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,8); // the first 8 bytes memloc += 16; 但是它在Array.copy中抛出了一个错误(sendBuf memloc,8);因为运算符”不能应用于’byte []’和’int’类型的 *** 作数.
怎么能实现这个???? :) 请帮忙 :)
解决方法for(int i = 0; i < 8; i++){ sendBuf[i+memloc] = Convert.ToSByte(version[i]);} 总结 以上是内存溢出为你收集整理的c# – 在我的WPF应用程序中无法使用Array.Copy()全部内容,希望文章能够帮你解决c# – 在我的WPF应用程序中无法使用Array.Copy()所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)