字节数组通过类属性 [英] byte array via a class property

查看:60
本文介绍了字节数组通过类属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字节数组,我需要发送到一个类,它将存储在一个arraylist中。


我用的是类中的以下属性接受字节数组,但是它看起来好像是数组以某种方式被破坏了。我的声明是错的

某处?

公共WriteOnly属性BytesAdd()As Byte()

Set(ByVal Value()作为Byte)

pBytes.Add(超值)

结束套件

结束物业


谢谢。

I have a byte array, which i need to send to a class, where it will be
stored in an arraylist.

I use the following property in the class to accept the byte array, but it
seems that the array is getting corrupted somehow. Is my declaration wrong
somewhere?

Public WriteOnly Property BytesAdd() As Byte()
Set(ByVal Value() As Byte)
pBytes.Add(Value)
End Set
End Property

Thanks.

推荐答案

好的,我做了一些调试,发现虽然pBytes是一个arraylist,但每个

时间属性.add,一个新条目被添加到arraylist中,因为

预期,但是arraylist中的所有先前条目都等于这个

条目!有什么原因吗?
ok, i did some debugging and found that though pBytes is an arraylist, every
time the property does the .add, a new entry is added to the arraylist as
expected, BUT all the previous entries in the arraylist become equal to this
entry!! Any reason why?


也许每当我添加一个新的字节数组条目时,条目

作为参考而不是一个值,导致所有以前的条目

反映最新的添加?
Is it that perhaps every time i add a new entry of the byte array, the entry
is made as a reference and not a a value, which causes all previous entries
to reflect the latest addition?




" Saurabh库马尔" < au@sd.com>写了

"Saurabh Kumar" <au@sd.com> wrote
我有一个字节数组,我需要发送到一个类,它将被存储在一个arraylist中。

我使用以下属性在类中接受字节数组,但似乎数组以某种方式被破坏了。我的声明是错误的吗?

公共WriteOnly属性BytesAdd()As Byte()
设置(ByVal Value()As Byte)
pBytes.Add(Value )
结束集
结束属性
I have a byte array, which i need to send to a class, where it will be
stored in an arraylist.

I use the following property in the class to accept the byte array, but it
seems that the array is getting corrupted somehow. Is my declaration wrong
somewhere?

Public WriteOnly Property BytesAdd() As Byte()
Set(ByVal Value() As Byte)
pBytes.Add(Value)
End Set
End Property



你没有出示你的pBytes声明,或者你传递的内容

to财产。它在通过之前是否已损坏?没有人可以通过物业代码告诉




创建一个小型演示来说明问题,可以发布到

项目供他人检查和测试。修复你的代码要容易得多,而不是猜你用什么.....


LFS


You haven''t shown your declaration for pBytes, or what you are passing
to the property. Was it corrupted before it got passed? No one can tell
from just the property code.

Create a small demo to illustrate the problem, that can be posted into a
project for others to inspect and test. It is far easier to fix your code than
guess what you may be using.....

LFS


这篇关于字节数组通过类属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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