你好能有人告诉我在vb.net多维关联数组的一个例子。 需要数组来保存民族的名字,有年龄和其他一些设置。 希望能够使用词典使用People.Add。
谢谢
- 标记
你好能有人告诉我在vb.net多维关联数组的一个例子。 需要数组来保存民族的名字,有年龄和其他一些设置。 希望能够使用词典使用People.Add。
谢谢
- 标记
认为OOP。 您应该使用一个类来互相属性相关联。 例:
Class Person
Private _name as String
Private _age as Integer
Public ReadOnly Property Name
Get
Return _name
End Get
End Property
Public ReadOnly Property Age
Get
Return _age
End Get
End Property
Public Sub New(name As String, age as Integer)
_name = name
_age = age
End Sub
End Class
现在,你可以把人的字典:
Dim people As New Dictionary(Of String, Person)()
people.Add("John", new Person("John", 42))
people.Add("Jane", new Person("Jane", 12))