vb.net中的动态数组Bidimensional

时间:2015-08-21 01:36:49

标签: php vb.net

我想在vb.net中使用数组,但我不能,现在我更熟悉php,javascript,例如在php中我可以使用array_push添加新索引。这里的例子

$myarray=[];
array_push($myarray,array("AAAA","BBB"));

然后我可以用索引

来调用它
echo $myarray[0][1];  //result: BBB

但是在vb.net中我不知道我该怎么办?,我试试这个

dim myArray(0,1) as string
redim myArray(myArray.length-1,1)

myArray(myArray.length-1,0)
myArray(myArray.length-1,1)

但我没有相同的结果

1 个答案:

答案 0 :(得分:0)

谢谢@SLaks你有理由,这是其他人的解决方案

       Dim myarray As New List(Of Dictionary(Of String, String))()
      myarray.Add(New Dictionary(Of String, String)() From {{"ID", "AAA"}})
myarray.Add(New Dictionary(Of String, String)() From {{"value", "BBB"}})

并为每个

For Each subArray As Dictionary(Of String, String) In myArray
    Dim id As String = subArray("ID")
    Dim value As String = subArray("value")
Next