以下为测试代码:
Dim listVillage As New List(Of Village)(200)
 
        Dim newVillage As New Village
        newVillage.ID = "123456"
        newVillage.Name = "测试城市"
        listVillage.Add(newVillage)
        newVillage.ID = "654321"
        newVillage.Name = "测试城市"
        listVillage.Add(newVillage)        newVillage.ID = "654321"
        newVillage.Name = "测试城市"
        listVillage.Add(newVillage)        newVillage.ID = "654321"
        newVillage.Name = "测试城市"
        listVillage.Add(newVillage)        MsgBox(listVillage.Count)        For i As Integer = 1 To listVillage.Count
            Me.TextBox1.AppendText(listVillage.Item(i - 1).ToString)        Next我现在要TextBox1输出listVillage中的对象newVillage,应该如何做? 

解决方案 »

  1.   


    foreach( Village tempV in listVillage )
    {//tempV is the member of ListVillage
        Me.TextBox1.AppendText( tempV.Name )
    }vb.net 代码?
      

  2.   

    谢谢楼上的几位朋友 我这样取过,但是提示: vill.ID 未将对象引用设置到对象的实例         Dim vill As New Village        For Each vill In listVillage
                Me.TextBox1.AppendText(vill.ID)
            Next
      

  3.   


    For Each vill As Village In listVillage
          Me.TextBox1.AppendText(vill.ID)
    Next