我有一个现有的String
和HashSet(Of String)
,但是以下代码
Dim myDict As New Dictionary(Of String, HashSet(Of String))(myString, myHashSet)
产生此Intellisense错误:Argument matching parameter 'comparer' narrows from 'System.Collections.Generic.HashSet(Of String)' to 'System.Collections.Generic.IEqualityComparer(Of String)'
创建此词典的正确方法是什么?
答案 0 :(得分:4)
您可以使用Collection Initializer:
Dim myDict As New Dictionary(Of String, HashSet(Of String)) From
{{myString, myHashSet}}