How do I use HashSet as a dictionary key?

后端 未结 3 595
名媛妹妹
名媛妹妹 2020-12-16 10:51

I wish to use HashSet as the key to a Dictionary:

Dictionary, TValue> myDictionary = new Dictionary

        
3条回答
  •  独厮守ぢ
    2020-12-16 10:53

    You could use the set comparer provided by HashSet:

    var myDictionary = new Dictionary, TValue>(HashSet.CreateSetComparer());
    

提交回复
热议问题