这可能是我如何编写这篇文章的一个相当基本的问题,但我需要一些帮助:我有一个 odject 定义为具有两个字段的公共类,都是字符串
Public Class mp
Dim _fg As String
Dim _scode As String
Property fg As String
Get
Return _fg
End Get
Set(ByVal value As String)
_fg = value
End Set
End Property
Property scode As String
Get
Return _scode
End Get
Set(ByVal value As String)
_scode = value
End Set
End PropertyEnd Class
然后我定义了一个数组:
Dim mps As New List(Of mp)()
然后在一个循环中,我先清除它后开始添加到列表中:
Dim mpholder As New mp
cmd.CommandText = 'Query here
cmd.ExecuteNonQuery()
reader = cmd.ExecuteReader
mp.Clear()
Try
Do While reader.Read()
mpholder.fg = ""
mpholder.scode = ""
mpholder.fg = reader(0)
mpholder.scode = reader(1)
mps.Add(mpholder)
Loop
Catch ex As Exception
MP_Res.Text = "error"
End Try
如果我在某个阶段遇到错误并抓住了问题,则列表“mp”中的条目数量相同,但它们都是空的