Reputation: 3451
I've got an existing String
and HashSet(Of String)
, but the following code
Dim myDict As New Dictionary(Of String, HashSet(Of String))(myString, myHashSet)
yields this Intellisense error: Argument matching parameter 'comparer' narrows from 'System.Collections.Generic.HashSet(Of String)' to 'System.Collections.Generic.IEqualityComparer(Of String)'
What's the right way to create this dictionary?
Upvotes: 3
Views: 2923
Reputation: 564333
You can use a Collection Initializer:
Dim myDict As New Dictionary(Of String, HashSet(Of String)) From
{{myString, myHashSet}}
Upvotes: 7