如何在vb.net中将字典条目添加到另一个字典

时间:2015-02-14 20:27:19

标签: vb.net dictionary

我有这三本词典

    dictLibraries.Add("SVSU", "Zahnow Library")
    dictLibraries.Add("BR", "Fleschner Memorial Library")
    dictLibraries.Add("SDJ", "Scott D. James Technical Repository")

    dictBooks.Add("101", "Zen and the Art of Appliance Wiring")
    dictBooks.Add("102", "Interpretive Klingon Poetry")
    dictBooks.Add("103", "Doing More With Less - Navel Lint Art")
    dictBooks.Add("104", "Data Structures for Fun and Profit")
    dictBooks.Add("105", "Programming with the Bidgoli")

    dictMedia.Add("201", "CD - IEEE Computer: the Hits")
    dictMedia.Add("202", "DVD - The Pirates of Silicon Valley")
    dictMedia.Add("203", "DVD - Databases and You: the Video Experience")

然后我想制作另一本字典

Public mynesteddict As New Dictionary(Of String, Dictionary(Of String, String))

在这本词典中我想要" SVSU",dictboooks(" 101"," Zen和家电布线艺术")

我该怎么做

1 个答案:

答案 0 :(得分:1)

  1. 创建与dictbooksdictbooks_1),
  2. 相同的词典
  3. 从里面的dictbooks中复制你想要的东西,
  4. 然后将值添加到mynesteddict

    Dim mynesteddict As New Dictionary(Of String, Dictionary(Of String, String))
    Dim dictBooks_1 As New Dictionary(Of String, String)
    dictBooks_1.Add("101", dictBooks("101"))
    mynesteddict.Add("SVSU", dictBooks_1)