收到字节数组复制到另一个字节数组 [英] received byte array copy to another byte array

查看:90
本文介绍了收到字节数组复制到另一个字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..

我想在一个atime时从serialport.One字节接收200个字节。当我从串口接收到第一个字节时,我想将它存储在字节数组的第一个位置接收到第二个字节后,将存储在字节数组的第二个位置...

Hi..
I want to receive 200 bytes from serialport.One byte at a atime.And when i receive first byte from the serialport,i want to store it in a byte array's first position.After that when receive second byte,that will store in the second position of the byte array...

推荐答案

这很简单:

That's easy:
private byte[] data = new byte[200];
private int index = 0;
...
   if (index < data.Length)
      {
      data[index++] = recievedByteValue;
      }


我找到了解决方案。我将字节数组声明为静态字节数组....
I found the solution..I declared byte array as static byte array....


这篇关于收到字节数组复制到另一个字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆