0

我必须创建多个字典;80-300。知道如何从变量列表中创建这些字典吗?IE

我有 ("0001","0003","0002","0005",..) 我需要创建一个数字字典列表吗?

Dim $$$$ As Dictionary(Of Integer, String)

谢谢

4

1 回答 1

1

这能解决你的问题吗?

Public Function CreateDictionariesDictionary(sourceList as IList(Of String)) As IDictionary(Of String, IDictionary(Of Integer, String))
    Dim returnDic As New Dictionary(Of String, IDictionary(Of Integer, String))

    For Each sourceItem In sourceList
        returnDic(sourceItem) = New Dictionary(Integer, String)
    Next

    Return returnDic
End Function

然后,您可以从主字典中检索它们,而不是通过变量名访问每个字典。

Dim mainDictionary = CreateDictionariesDictionary(mySourceList)
Dim dictionaryForKey = mainDictionary("key")
于 2013-09-20T11:49:05.940 回答