代码在vb.net中
Structure FeeComponent
Public id As Integer
Public sName As String
Public oFee As List(new FeeDetail)
End Structure
另一种结构
Structure FeeDetail
Public rollNo As Integer
Public address As String
Public age As Integer
End Structure
在函数中执行sql查询并将结果存储在Reader中,我想以以下方式向主Structure FeeComponent添加一些详细信息
Dim Retval As New List(Of Idemo.FeeComponent)
Dim Fee As New List(Of Idemo.FeeDetail)
Dim Temp As New Idemo.FeeComponent
Dim Fees As New Idemo.FeeDetail
While Reader.Read
With Temp
.id = Reader.Item("id")
.sName = Reader.Item("Name")
With Fees
.rollNo = Reader.Item("roll")
.address = Reader.Item("add")
.age = Reader.Item("age")
Temp.Fee.Add(Fees)
End While
在Temp.Fee.Add(Fees)行上显示错误 如何更正代码我已尽我所能,但我无法更正代码。 我刚开始使用vb,所以请帮忙 错误消息是 System.NullReferenceException:对象引用未设置为对象的实例