If you need to create a List object by reading a file and want to have each separate line as a list item, here is what you can do.
//File name
const string f = "TextFile1.txt";
// Declare new List.
List<string> lines = new List<string>();
// Use using StreamReader for disposing.
using (StreamReader r = new StreamReader(f))
{
string line;
while ((line = r.ReadLine()) != null)
{
lines.Add(line);
}
}
And then if you wish to convert this list into an array, you can use the .ToArray() method of the List object.
string[] arrayOfLines = lines.ToArray();
I hope i got your question correctly and this helps. Thanks.