I want to create a strongly typed multidimensional array or collection containing the following values from a database:
Requirements:
Thanks for the great answers everyone. Here's what I went with... :)
Structure FileRecord
Dim Name As String
Dim Size As Integer
Sub New(ByVal FileName As String, ByVal FileSize As Integer)
Me.Name = FileName
Me.Size = FileSize
End Sub
Sub New(ByVal Files() As FileRecord)
For Each f As FileRecord In Files
Dim fr As New FileRecord(f.Name, f.Size)
Next
End Sub
End Structure
You can't have a multidimensional array containing two separate types.
Instead, you'd typically make a single dimensional array (or List(Of T)
) containing a custom class with your data.
In your case, you might want something like:
Public Class FileRecord
Public Property Name As String
Public Property Size as Integer
End Class
Then, make a List(Of FileRecord)
to hold your data. You'd then be able to access this as:
Dim nameAtIndex = theList(i).Name
Dim sizeAtIndex = theList(i).Size