Sharif Mamun
Sharif Mamun

Reputation: 3554

C# - How can I correct string case in HashSet<string> within a Dictionary

I have a variable like below:

var dict = new Dictionary<string, HashSet<string>>();

I want to make sure the values in the HashSet are unique using StringComparer.Ordinal. What would be the syntax for that? Thanks.

Upvotes: 0

Views: 63

Answers (1)

Tanveer Badar
Tanveer Badar

Reputation: 5523

Everytime you initialize a new key, the value should be passed an explicit parameter like this:

dict["some key"] = new HashSet<string>(StringComparer.Ordinal);

Upvotes: 3

Related Questions