我必须创建多个词典; 80-300。知道如何从变量列表中创建这些词典吗?即。
我有(“0001”,“0003”,“0002”,“0005”,..)我需要创建一个数字列表的字典?
Dim $$$$ As Dictionary(Of Integer, String)
由于
答案 0 :(得分: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")