将这个PHP数组更改为vb.net



我目前正在使用vb.net循环并在控制台上写:

fruits orange 
fruits banana
fruits apple
numbers 1
numbers 2
numbers 3
numbers 4
numbers 5
numbers 6
etc...

但是,我希望像这样存储我的值:

array (
  "fruits"  => array (
    "a" => "orange",
    "b" => "banana",
    "c" => "apple"
  ),
  "numbers" => array (1,2,3,4,5,6),
  "holes"   => array (
         "first",
    5 => "second",
         "third"
  )
);

那么当我得到这个时,我想循环遍历每个

array (
  "fruit" => "orange",
  "b" => "banana",
  "c" => "apple"
)

并检查某些值。我可以很容易地在php中做到这一点,然而,vb.net给我留下了arh。

任何想法?

您也可以在vb.net中轻松地做到这一点。

    Dim arr As Dictionary(Of String, Object) = New Dictionary(Of String, Object)
    arr.Add("fruits", {"orange", "banana", "apple"})
    arr.Add("numbers", {1, 2, 3, 4, 5, 6})
    arr.Add("holes", {"first", "second", "third"})
    For Each key As KeyValuePair(Of String, Object) In arr
        For Each obj As Object In key.Value
            Console.WriteLine(key.Key & " " & obj.ToString)
        Next
    Next
    Console.ReadLine()

相关内容

  • 没有找到相关文章

最新更新