vb.net 结构体 数组 在线等 求解答
在数据层
Public Structure student
Public id As Integer
Public name As String
End Structure
假设定义这样一个结构体 。建立一个这结构体的数组
dim students() as student
能否实现向数组中添加 一个一个student结构体的对象。
假设有一个方法要操作一个这个结构体数组。
存成2个数组会不会更好。
[解决办法]
Public Structure Student
Public id As Integer
Public name As String
End Structure
Sub DoSomething
Dim Students As New List(Of Student)
Students.Add(New Student With {.id="001",.name="hunan"})
Students.Add(New Student With {.id="002",.name="jiangsan"})
Students.Add(New Student With {.id="003",.name="huaxi"})
For Each st In Students
MsgBox("st.name")
Next
End Sub