Dim texts As New Dictionary(Of String, Dictionary(Of String, String))
如何将数据添加到上面的字典?
答案 0 :(得分:3)
假设您使用visual studio,您应该在键入texts.Add(
密钥为String
,值为Dictionary(Of String, String)
。添加值的一种方法是预先声明一个新字典,然后添加它
Dim texts As New Dictionary(Of String, Dictionary(Of String, String))()
Dim innerEnglish As New Dictionary(Of String, String)()
innerEnglish.Add("A", "Antelope")
innerEnglish.Add("B", "Bear")
texts.Add("English", innerEnglish)
Dim innerLatin As New Dictionary(Of String, String)()
innerLatin.Add("O", "Oryx")
innerLatin.Add("U", "Ursa")
texts.Add("Latin", innerLatin)
他们可以这样键入
texts("Latin")("U") ' returns "Ursa"
texts("English")("B") ' returns "Bear"