开发者

Unique set of strings in C#

I have a list of strings, I need to be able to simply probe if a new string is in the table or not. When the list is large, te开发者_运维问答sting a simple list directly is pretty inefficient... so typically I use a Dictionary to get constant lookup speeds, although I don't actually care about the value. This seems like a misuse of a dictionary, so I'm wondering what other approaches I could take.

Is there a better way to do hit testing that I am unaware of?


You should use a HashSet<string>, which is specifically designed for this purpose.


A HashSet is better suited than a Dictionary, for this purpose.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜