如何将值添加到列表中的项目。列表类型是此类:-
<SoapType("TOBWeeksHeld", "urn:daeoverbrandIntf")> _
Public Class TOBWeeksHeld
Public siteID As String
Public checkIn As String
Public resortName As String
Public country As String
Public region As String
Public locality As String
Public weekId As String
Public bedrooms As String
Public sleeps As String
Public bookingType As String
Public resortId As String
Public timeToExpiry As String
Public specialFlag As String
Public extMemberNo As String
End Class
我尝试的一切,例如:-
Dim newWeeksOnHold As New List(Of TOBWeeksHeld)
With newWeeksOnHold(0)
.siteID = siteID
.checkIn = weeksOnHold.daeWeeksHeld(i).checkIn()
.resortName = weeksOnHold.daeWeeksHeld(i).resortName()
.country = weeksOnHold.daeWeeksHeld(i).country()
.region = weeksOnHold.daeWeeksHeld(i).region()
.locality = weeksOnHold.daeWeeksHeld(i).locality()
.weekId = weeksOnHold.daeWeeksHeld(i).weekId()
.bedrooms = weeksOnHold.daeWeeksHeld(i).bedrooms()
.sleeps = weeksOnHold.daeWeeksHeld(i).sleeps()
.bookingType = weeksOnHold.daeWeeksHeld(i).bookingType()
.resortId = weeksOnHold.daeWeeksHeld(i).resortId()
.timeToExpiry = weeksOnHold.daeWeeksHeld(i).timeToExpiry()
.specialFlag = weeksOnHold.daeWeeksHeld(i).specialFlag()
.extMemberNo = weeksOnHold.daeWeeksHeld(i).extMemberNo()
End With
在调试器中给我同样的错误,即索引超出“With newWeeksOnHold(0)”行的范围。我猜这是因为列表是空的,我告诉它去一个特定的索引。但是,我尝试过添加、插入和其他一些操作,但均无济于事。
这样做的目的是读入 Web 服务结果并将其作为不同的类输出。
任何帮助,将不胜感激。