有没有办法在visual basic中创建两种不同类型的标准数组?
示例:
Array [string []] [int []]
| number1 | 1 | | number2 | 2 |
答案 0 :(得分:0)
数组只能是单一类型。我会推荐一个班级
例如
Public Class ExampleClass
Dim strVariable As String
Dim intVariable As Variable
End Class
'You can then declare the class as a list
Dim twoDataTypesInOne As New List(Of ExampleClass)
'Adding to the list would be
twoDataTypesInOne.Add(New ExampleClass() With {
.strVariable = "number3", _
.intVariable = 3 _
})
答案 1 :(得分:0)
是。您可以创建一个对象数组,然后可以将所有内容分配给该数组。
Dim myArray(2) As Object
myArray(0) = "somestring"
myArray(1) = 2