I'm trying to initialize a List<string>
with some data from a file. The file is a list of words separated by carriage returns so currently, I am doing
var wordList = new List<string>(textFromFile.Split( new[] {"\r\n", "\r", "\n"}, StringSplitOptions.None ) )
but for the size of text files I'm dealing with (172,888 lines in one of the files!) this is very slow. Is there a better way to do this? The text file doesn't have to be formatted the way it is currently, I could parse it and write it out in a different format if there is a better method of storing the data. In C++ I would be thinking of binary data and a memcopy but I don't think there is a similar solution in C#?
If it's relevant, the code is in a Unity app so limited to early .NET capabilities of their Mono version