0

I'm making a simple Word Builder type of game (where one player enters a word, and the other player enters a word starting with the last letter of the first player's word), so for it to work, I've got a list that is supposed to contain all words in the dictionary. I've got a text file that has 350k+ words, like this:

aahed
aahing
aahs
aal
aalii
aaliis
aals
aam
aani
aardvark
aardvarks
aardwolf
aardwolves
aargh
aaron
aaronic
aaronical
aaronite
aaronitic

and so on. How can I import them all as a list in C#? If there is a better way of doing it then please let me know! I'm sorry if this is a dumb question.

Jamal H.A
  • 37
  • 2
  • 7

1 Answers1

1

You could try use File.ReadLines to read the text files lines, this will return a string array with all the entries in it and then you can either use that array by itself or pass it to a List<string> e.g.:

string[] words = File.ReadLines(@"C:\dictionary.txt");

// List<string> listOfWords = new List<string>(words);
Space
  • 175
  • 9