【发布时间】:2012-05-25 13:57:51
【问题描述】:
我正在尝试将字节数组复制到第三方库中的类中
Dim usr As New RSI_USER_RECORD
Dim ba(RSI_USER_RECORD.RSI_LEN_USER_REC - 1) As Byte
'populate ba here
usr = ba 'how can I do this?
这可能吗?
这是类的定义(来自Reflector)
Public Class RSI_USER_RECORD
' Methods
Public Function Clone() As RSI_USER_RECORD
Return New RSI_USER_RECORD With { _
.pID = Me.pID.Clone, _
.pTemplateVector = Me.pTemplateVector.Clone, _
.authorityLevel = Me.authorityLevel, _
.rejectThreshold = Me.rejectThreshold, _
.timeZone = Me.timeZone _
}
End Function
' Fields
Public authorityLevel As RSI_AUTHORITY_LEVEL = RSI_AUTHORITY_LEVEL.RSI_AUTHORITY_NONE
Public pID As RSI_ID = New RSI_ID
Public pTemplateVector As RSI_TEMPLATE = New RSI_TEMPLATE
Public rejectThreshold As UInt16 = 0
Public Const RSI_LEN_USER_REC As Integer ModOpt(IsConst) = &H10
Public timeZone As Byte = 0
End Class
【问题讨论】:
-
这个类对象最初是如何出现在字节数组中的?
-
@HansPassant - 我正在从作为字节数组返回的硬件设备中读取一个数据块,每个 16 字节块是一个 USER_RECORD
-
那么它确实是一个结构。 stackoverflow.com/a/1936208/17034
-
是的,它看起来像对象浏览器报告的结构:
Public Class USER_RECORD Inherits System.Object
标签: .net vb.net arrays data-structures