Converting Text to a String Array Format

So I have a text file with 230,000 words (Essentially every word in the English dictionary, I got it from the MOBY project) and it is set up like this:

Angry
Answer
Ants

And so on. So each word in the text file has a line break after.

I want to copy and paste the entirety of each letter section into it’s own array in my script (C#).

So it would be something like (Which I think is correct but I’m not sure):

string Awords = new string {“Angry”,“Answer”,“Ants”, And so on…};

But my problem is I’m dealing with huge amounts of words here, so I can’t take the time to turn:

Angry
Answer
Ants

to “Angry”,“Answer”,“Ants”

by hand since I’d have to do that for thousands of words. So I’m wondering if there’s some way to automate this process, which would be something like:

  1. Remove line break from end of word.
  2. Add " to beginning of word and ", to end.

I was hoping maybe someones already made a program for this since it would be one of the first steps in making any sort of word game. Or possibly there is already a text file online in this format?

My second, related, question is am I going about this the right way? With Arrays and such?

Anyway, thanks for your time.

What I would do is create a text file with your words in it and then put that file into your project inside a Resources folder.

Then you can use:

  var textFile = Resources.Load("NameOfFileWithoutExtension", typeof(TextAsset)) as TextAsset; //C#

To get the resource and then make an array using:

  var textArray = textFile.text.Split('

'); //C#

Or perhaps even better also turn it into a dictionary so you can look it up! You could use Linq for that

  using System.Linq;

  ...

  Dictionary<string, bool> words;

  ...

  words = textFile.text.ToDictionary(s=>s,s=>true);

This lets you use things like ContainsKey which is very fast to find a word.

String lines = File.ReadAllLines(“customfiles/dictionary.txt”);

Pretty much just telling it to find YourGameDirectory\customfiles\dictionary.txt and read each line as a new array item.