Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 789
tbischel Avatar asked Dec 17 '09 02:12

tbischel


People also ask

What is unique string?

A String is said to be 'Unique' if none of the alphabets resent in the string are repeated. Write a program to accept a string and check whether the string is Unique or not. Example :- Input: COMPUTER. Output:Unique String.

What is unique in C language?

Unlike most other modern languages such as Java, C++ and JavaScript, C does not provide a separate type for strings. A string is considered an array of characters terminated by a 0 character (denoted "\0"). The length of the string is denoted by a convention: the number of characters until the 0 character.


1 Answers

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

like image 90
SLaks Avatar answered Sep 25 '22 18:09

SLaks