C# - How to read all lines in a file to an array or list

In C# it is quite convenient to read all files to an array. You can use the method ReadAllLines() from the File class, all it needs is a path to the file that you want to read. This does just what you are looking for, here is an example:

var lines = File.ReadAllLines("C:\\someTextFile.txt");

Using the above you will have an array containing each line of the file as a string, you can then call ToList(); to get it as a list.

I hope this helps you :)