我想製作一個多維的關聯數組。我想它,所以我可以有這樣的:使用字典的多維數組
someVar(日期)(小時)(類別)= MSSQL查詢
我使用下面的嘗試和準備,但我有麻煩將數據添加到陣列。
Dim test As New Dictionary(Of Integer, Dictionary(Of String, String))
Dim test2 As New Dictionary(Of String, String)
任何幫助,非常感謝。
-----編輯: 這是我使用的,它的工作原理。 Doe ayone明白爲什麼這將是一個不好的方法來做到這一點?
Dim test As New Dictionary(Of Integer, Dictionary(Of String, String))
Dim SomeNum As Integer = 0
Dim someStr As String = "This is a string: "
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
While SomeNum < 100
Dim someNum2 As Integer = 0
Dim test2 As New Dictionary(Of String, String)
While someNum2 < 100
test2.Add(CType(someNum2, String), someStr & CType(someNum2, String))
someNum2 += 1
End While
test.Add(SomeNum, test2)
SomeNum += 1
End While
For Each kvp As KeyValuePair(Of Integer, Dictionary(Of String, String)) In test
Dim ccc As String = ""
Dim ddd As String = ""
Dim v1 As String = CType(kvp.Key, String)
Dim v2 As Dictionary(Of String, String) = kvp.Value
lblOne.Items.Add("Key: " & v1)
For Each kvp2 As KeyValuePair(Of String, String) In v2
Dim v3 As String = kvp2.Key
Dim v4 As String = kvp2.Value
lblTwo.Items.Add("SubKey: " & v3 & " Value: " & v4)
lblOne.Items.Add("")
Next
lblOne.Items.Add(v1 & " End--------------")
lblTwo.Items.Add(v1 & " End--------------")
Next
End Sub
給我們多一些關於如何在代碼中看到它的例子?要添加到它的電話和從中檢索的電話是什麼樣的? – RBarryYoung 2013-04-29 20:32:31
我需要能夠存儲一個密鑰,例如一個日期,並在該日期內,我需要獲得每個類別的小時銷售。 (我不直接擔心查詢部分,一旦我得到這部分工作,我會弄清楚查詢。)我編輯了這個問題,以顯示我的工作。 – 2013-04-29 21:36:38