The question that I have is regarding converting the process of reading lines from a text file into an array instead of just reading it.
The error in my codes appear
File.ReadLines()
returns an object of type System.Collections.Generic.IEnumerable
File.ReadAllLines()
returns an array of strings.
If you want to use an array of strings you need to call the correct function.
You could use Jim solution, just use ReadAllLines()
or you could change your return type.
This would also work:
System.Collections.Generic.IEnumerable lines = File.ReadLines("c:\\file.txt");
You can use any generic collection which implements IEnumerable. IList for an example.