嘿,我有大约4个dicionarys持有variuos事物的值。每个字典对于每个字典中的每个项目都有相同的密钥。VB.net在所有字典中找到相同的密钥
例子:
dictionary1 (string, string):
key = 523697777, value = "bobs burgers"
key = 89557, value = "Blah blah 1"
key = 598823644, value = "something"
dictionary2 (string, string):
key = 523697777, value = "oats and honey"
key = 89557, value = "juicyfruit"
key = 598823644, value = "sun glasses"
dictionary3 (string, datetime):
key = 523697777, value = 01/05/2013 00:00:00
key = 89557, value = 01/24/2013 00:00:00
key = 598823644, value = 03/12/2013 00:00:00
dictionary4 (string, string):
key = 523697777, value = "Computers"
key = 89557, value = "IM"
key = 598823644, value = "cans"
现在我想能够只是循环,并从每个dicionary正确的值,而无需通过每个dicionary seprate不必循环。
Currenly我这样做:
Dim allTogether As New StringBuilder
For Each dict1 In dictionary1
For Each dict2 In dictionary2
If dict1.Key = dict2.Key Then
allTogether.Append(dict1.Value)
allTogether.Append(dict2.Value)
For Each dict2 In dictionary3
If dict2.Key = dict3.Key Then
allTogether.Append(dict3.Value)
For Each dict2 In dictionary3
If dict3.Key = dict4.Key Then
allTogether.Append(dict4.Value)
End If
Next
End If
Next
End If
Next
Next
应该产生:
bobs burgers oats and honey 01/05/2013 00:00:00 Computers
Blah blah 1 juicyfruit 01/24/2013 00:00:00 IM
something sun glasses 03/12/2013 00:00:00 cans
是否有可能得到一举中的数据?
所以基本上给了一个键,你想从同一个键的所有4个字典中获取值? –
@YuriyGalanter正确。 – StealthRT