我是.Net的新手,多年来一直没有用Visual Basic编写代码。我在向数组赋值时遇到问题并且收到错误,“类型MemberFocal.Member的值无法转换为System.Array” - MemberFocal.Member是自定义类的一部分,我正在尝试创建一个数组这些对象。任何帮助是极大的赞赏。这是代码:
Public Function CreateMembersFromDataSet(ByVal memberDs As DataSet) As Array
Dim returnval() As Array
Dim memberTable As DataTableCollection
Dim i As Integer = 0
memberTable = memberDs.Tables
For Each row As DataRow In memberTable
' error occurs on the following line
returnval(i) = Me.CreateMemberWithId(row.Item("id").ToString)
i += 1
Next
Return returnval
End Function
答案 0 :(得分:4)
Dim returnval() As Array
会创建一个Array
值数组。
您想要Dim returnval() As Member
。