views:

85

answers:

2

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, testing 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?

A: 

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

Noon Silk
+5  A: 

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

SLaks