c# - string handling -


i know if have english dictionary in text file best way check whether given string proper , correct english word. dictionary contains 100000 english words , have check on average of 60000 words in 1 go. looking efficient way. should store strings first or process them generated.

thanx

100k not great number, can pop in hashset<string>.

hashset lookup key-based, lightning fast.

example how might in code is:

string[] lines = file.readalllines(@"c:\mydictionary.txt"); hashset<string> mydictionary = new hashset<string>(); foreach (string line in lines) {   mydictionary.add(line); }  string word = "aadvark"; if (mydictionary.contains(word)) {   console.writeline("there aadvark"); } else {   console.writeline("the aadvark lie"); } 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -