Hi can someone show me an example of a multidimensional associative array in vb.net. Need array to hold peoples name, there age and a few other settings. Want to be able to use a Dictionary to use People.Add.
Thanks
--Mark
Hi can someone show me an example of a multidimensional associative array in vb.net. Need array to hold peoples name, there age and a few other settings. Want to be able to use a Dictionary to use People.Add.
Thanks
--Mark
Think OOP. You should use a class to associate the properties with each other. Example:
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
Now you can put the people in a dictionary:
Dim people As New Dictionary(Of String, Person)()
people.Add("John", new Person("John", 42))
people.Add("Jane", new Person("Jane", 12))